Skip to content

Instantly share code, notes, and snippets.

@CesarValiente
Last active April 25, 2018 18:24
Show Gist options
  • Save CesarValiente/7c95480bc487c9551abad9cdb73a5245 to your computer and use it in GitHub Desktop.
Save CesarValiente/7c95480bc487c9551abad9cdb73a5245 to your computer and use it in GitHub Desktop.
class PersistenceSideEffect(val store: Store,
persistenceThread: ThreadExecutor? = null): SideEffect(persistenceThread) {
init {
store.sideEffects.add(this)
}
override fun handle(action: Action) {
when (action) {
is CreationAction -> CreationHandler.handle(action) { store.dispatch(it) }
is UpdateAction -> UpdateHandler.handle(action) { store.dispatch(it) }
is ReadAction -> ReadHandler.handle(action) { store.dispatch(it) }
is DeleteAction -> DeleteHandler.handle(action) { store.dispatch(it) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment