Created
December 12, 2017 14:42
-
-
Save digitalbuddha/8e682ce7288cbbaf59f2b33cb20a2ff9 to your computer and use it in GitHub Desktop.
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
@Singleton | |
class Dispatcher @Inject | |
constructor(val stateSubject: PublishSubject<State>) { | |
val showEvents: Stack<State> = Stack() | |
fun dispatch(state: State) = stateSubject.onNext(state) | |
fun dispatchShow(state: State) { | |
showEvents.push(state) | |
Timber.d("pushing " + showEvents.peek()) | |
stateSubject.onNext(state) | |
} | |
//showing events | |
fun noNetwork() = stateSubject.ofType(Showing.NoNetwork::class.java) | |
fun showingFailure() = stateSubject.ofType(Showing.Failure::class.java) | |
fun showingSuccess() = stateSubject.ofType(Showing.Success::class.java) | |
fun showingArView() = stateSubject.ofType(Showing.ArView::class.java) | |
//non showing events | |
fun arTargetFound() = stateSubject.ofType(State.ArTargetFound::class.java) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment