Skip to content

Instantly share code, notes, and snippets.

@gumil
Last active February 17, 2019 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gumil/8da8d832c5152960665d0b8562932155 to your computer and use it in GitHub Desktop.
Save gumil/8da8d832c5152960665d0b8562932155 to your computer and use it in GitHub Desktop.
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