use of io.requery.rx.RxResult in project requery by requery.
the class RxTest method testQuerySelfObservableMap.
@Test
public void testQuerySelfObservableMap() throws Exception {
final AtomicInteger count = new AtomicInteger();
Subscription subscription = data.select(Person.class).limit(2).get().toSelfObservable().flatMap(new Func1<RxResult<Person>, Observable<Person>>() {
@Override
public Observable<Person> call(RxResult<Person> persons) {
return persons.toObservable();
}
}).subscribe(new Action1<Person>() {
@Override
public void call(Person persons) {
count.incrementAndGet();
}
});
data.insert(randomPerson()).toBlocking().value();
data.insert(randomPerson()).toBlocking().value();
assertEquals(3, count.get());
subscription.unsubscribe();
}
Aggregations