Created
June 19, 2015 22:46
-
-
Save jtremback/7be76c2816edf48df3b7 to your computer and use it in GitHub Desktop.
Persistent store- bad idea actually
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersistentStore extends Store { | |
handle (state, type, payload) { | |
const newState = super.handle(state, type, payload) | |
this.setItem(this.key, newState.toJS()) | |
return newState | |
} | |
async setPersistedStateAsync (reactor) { | |
debugger | |
const persistedState = await this._getPersistedStateAsync() | |
reactor.dispatch(this.key, persistedState) | |
return null | |
} | |
async _getPersistedStateAsync () { | |
let persistedState = await this.getItem(this.key) | |
persistedState = toImmutable(persistedState || {}) | |
return persistedState | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment