I have trouble with concat two RealmResults, can i get result as RealmResults
or only List ?
Observable
Observable
Observable.concat(asyncObservable1, asyncObservable2).startWith(asyncObservable1). .filter(RealmResults::isLoaded)
.subscribe(this::filterObserver);
void filterObserver(RealmResults
updateRealmResults(words);
}
I need filter Realm database filter by string with formatting:
Needle?
?Needle?
?Needle
RealmResults<Cat> equalTo;
RealmResults<Cat> beginsWith;
@Override
public void onViewRestored() {
compositeSubscription = new CompositeSubscription();
equalTo = realm.where(Cat.class).equalTo("field", filterString).findAllSorted("field");
beginsWith = realm.where(Cat.class).beginsWith("field", filterString).findAllSorted("field");
compositeSubscription.add(realm.asObservable()
.switchMap(new Func1<Realm, Observable<Cat>>() {
@Override
public Observable<Cat> call(Realm realm) {
return Observable.concat(Observable.from(equalTo), Observable.from(beginsWith));
}
})
.toList()
.subscribe(cats -> {
// update adapter with List<Cat>
}));
Maybe someone smarter can make it work with the Async operators and filter too.
Can the like predicate (see #3752) be of any use here?
Yes, (like) predicate is best for my task, buy i used Realm version below 2.0
You cannot concatenate RealmResults but doing a Or of two queries is supported.
Most helpful comment
You cannot concatenate
RealmResultsbut doing aOrof two queries is supported.