Skip to content

Instantly share code, notes, and snippets.

@ericntd
Last active September 9, 2021 17:43
Show Gist options
  • Save ericntd/1f1cd536fe05c8859d47a8f328d0bdbb to your computer and use it in GitHub Desktop.
Save ericntd/1f1cd536fe05c8859d47a8f328d0bdbb to your computer and use it in GitHub Desktop.
val inputSubject = PublishSubject.create<String>() // immutable!
val inputSubjectReadOnly = inputSubject.debounce(500L, TimeUnit.MILLISECONDS)
val someViewModel = SomeViewModel(inputSubjectReadOnly, ...)
override fun onSomeButtonClicked(...) {
// process success/ failure, extract data
inputSubject.onNext(data) // emit to input stream ViewModel consumes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment