Last active
August 11, 2016 11:03
-
-
Save Zhuinden/73b252c7c44ca00e794f8cd94a43a9e9 to your computer and use it in GitHub Desktop.
Realm Rx asObservable() example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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