Combining engines #126
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MichaelContento/redux-storage#126
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've written a custom engine that I only want to use for a few keys in my state. The rest of them, I'd like to use
redux-storage-engine-localstoragefor. I assumed from the naming that this is whatredux-storage-merger-immutablejswas for, but that doesn't appear to be the case.My attempted approach:
So what should I be doing here?
After a few more minutes of thought, I can pretty easily write an engine (or decorator, or whatever the terminology should be) that does what I expected the merger to do...
The job of a merger in redux-storage is to merge (hence the name 😄 ) the current state with state loaded from the engine (see https://github.com/michaelcontento/redux-storage/blob/master/src/reducer.js#L8).
Thus a merger would not be the right place to handle multiple engines. The best way would be to create a new engine, as it would be able to handle both
loadandsaveoperations. A rough API could look something like this:In this, very very rough, API we simply pass a object to our new router-engine which serves as a routing layer.
state.userwould be stored in the localStorage keyuserState,state.todosintodosStateand every other property ofstateindefaultState.Does this answer your question? If so, please close this issue 😄
I'll go ahead and close this issue now, as it seems to be inactive / solved. Feel free to reopen if this issue still exists!