Skip to content

Instantly share code, notes, and snippets.

@exallium
Created January 4, 2017 17:45
Show Gist options
  • Save exallium/1f3cea65564aec6b215024cab34e130b to your computer and use it in GitHub Desktop.
Save exallium/1f3cea65564aec6b215024cab34e130b to your computer and use it in GitHub Desktop.
rxmvp
interface Model {
fun first10Users(): Observable<List<Data>>
}
interface View {
fun displayUserList(users: List<Data>)
fun backButtonClicks(): Observable<ClickEvent>
}
class Presenter {
@Inject
lateinit var model: Model
@Inject
lateinit var view: View
/* injection */
fun setup() {
model.first10Users()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { view.displayUserList(it) }
view.backButtonClicks()
.debounce(1000)
.subscribe { dismiss() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment