Last active
February 17, 2019 21:15
-
-
Save gumil/8da8d832c5152960665d0b8562932155 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
Kaskade.create<ListAction, ListState>(ListState.Screen()) { | |
rx({ | |
object : DisposableObserver<ListState>() { | |
override fun onComplete() { | |
Timber.d("flow completed") | |
} | |
override fun onNext(state: ListState) { | |
Timber.d("currentState = $state") | |
} | |
override fun onError(e: Throwable) { | |
Timber.e(e, "Flow was interrupted") | |
process(ListAction.OnError(e).just()) | |
} | |
}.also { disposables.add(it) } | |
}) { | |
on<ListAction.Refresh> { | |
// get first 20 trending giphies from network | |
} | |
on<ListAction.LoadMore> { | |
// get next 20 trending giphies from network based on offset | |
} | |
} | |
on<ListAction.OnItemClick> { | |
ListState.GoToDetail(action.item) | |
} | |
on<ListAction.OnError> { | |
ListState.Error(R.string.error_loading) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment