Skip to content

Instantly share code, notes, and snippets.

@jungilhan
Last active May 11, 2018 03:28
Show Gist options
  • Save jungilhan/bd31288ad708f2819cd4252fbb58a541 to your computer and use it in GitHub Desktop.
Save jungilhan/bd31288ad708f2819cd4252fbb58a541 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
private val numbersObservable: BehaviorSubject<List<Int>>
= BehaviorSubject.createDefault(listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
override fun onCreate(savedInstanceState: Bundle?) {
...
swipeRefreshLayout.setOnRefreshListener {
numbersObservable.onNext(listOf(1, 2, 4, 5, 6, 7, 8, 9)) // pass a new list without 0, 3
}
numbersObservable.subscribe {
adapter.submitList(it)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment