Skip to content

Instantly share code, notes, and snippets.

@jtremback
Created June 19, 2015 22:46
Show Gist options
  • Save jtremback/7be76c2816edf48df3b7 to your computer and use it in GitHub Desktop.
Save jtremback/7be76c2816edf48df3b7 to your computer and use it in GitHub Desktop.
Persistent store- bad idea actually
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