Skip to content

Instantly share code, notes, and snippets.

@CesarValiente
Created May 13, 2017 04:35
Show Gist options
  • Save CesarValiente/697669836b89215035e0c0c4e29549a8 to your computer and use it in GitHub Desktop.
Save CesarValiente/697669836b89215035e0c0c4e29549a8 to your computer and use it in GitHub Desktop.
abstract class ControllerView(
protected val actionDispatcher: ActionDispatcher,
protected val stateDispatcher: StateDispatcher,
private val handleStateDifferentThread: ThreadExecutor? = null)
: LifecycleCallbacks, Subscriber<State> {
protected fun <T : Action> dispatch(action: T) {
actionDispatcher.dispatch(action)
}
override fun onNext(data: State) {
handleStateDifferentThread?.let { it.execute { handleState(state) } }
?: handleState(state)
}
abstract fun handleState(state: State)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment