Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Last active August 11, 2016 11:03
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 Zhuinden/73b252c7c44ca00e794f8cd94a43a9e9 to your computer and use it in GitHub Desktop.
Save Zhuinden/73b252c7c44ca00e794f8cd94a43a9e9 to your computer and use it in GitHub Desktop.
Realm Rx asObservable() example
private Subscription queryDogsByInput() {
return RxTextView.textChanges(editText)
.switchMap(charSequence -> realm.where(Dog.class)
.contains(DogFields.NAME, charSequence.toString())
.findAllSortedAsync(DogFields.NAME)
.asObservable()
).filter(RealmResults::isLoaded) // filter async results while not loaded
.subscribe(dogs -> adapter.updateData(dogs));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment