Created
May 13, 2017 04:35
-
-
Save CesarValiente/697669836b89215035e0c0c4e29549a8 to your computer and use it in GitHub Desktop.
This file contains 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
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