use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method realm_emittedOnUpdate.
@Test
@RunTestInLooperThread
public void realm_emittedOnUpdate() {
final AtomicInteger subscriberCalled = new AtomicInteger(0);
Realm realm = looperThread.realm;
subscription = realm.asObservable().subscribe(new Action1<Realm>() {
@Override
public void call(Realm rxRealm) {
if (subscriberCalled.incrementAndGet() == 2) {
looperThread.testComplete();
}
}
});
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method dynamicRealmResults_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void dynamicRealmResults_closeInDoOnUnsubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
Observable<RealmResults<DynamicRealmObject>> observable = dynamicRealm.where(AllTypes.CLASS_NAME).findAll().asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
dynamicRealm.close();
}
});
subscription = observable.subscribe(new Action1<RealmResults<DynamicRealmObject>>() {
@Override
public void call(RealmResults<DynamicRealmObject> allTypes) {
}
});
subscription.unsubscribe();
assertTrue(dynamicRealm.isClosed());
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method dynamicRealmObject_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void dynamicRealmObject_closeInDoOnUnsubscribe() {
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
Observable<DynamicRealmObject> observable = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst().<DynamicRealmObject>asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
dynamicRealm.close();
}
});
subscription = observable.subscribe(new Action1<DynamicRealmObject>() {
@Override
public void call(DynamicRealmObject obj) {
}
});
subscription.unsubscribe();
assertTrue(dynamicRealm.isClosed());
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method realm_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void realm_closeInDoOnUnsubscribe() {
Observable<Realm> observable = realm.asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
realm.close();
}
});
subscription = observable.subscribe(new Action1<Realm>() {
@Override
public void call(Realm rxRealm) {
}
});
subscription.unsubscribe();
assertTrue(realm.isClosed());
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method realmObject_closeInDoOnUnsubscribe.
@Test
@UiThreadTest
public void realmObject_closeInDoOnUnsubscribe() {
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
Observable<AllTypes> observable = realm.where(AllTypes.class).findFirst().<AllTypes>asObservable().doOnUnsubscribe(new Action0() {
@Override
public void call() {
realm.close();
}
});
subscription = observable.subscribe(new Action1<AllTypes>() {
@Override
public void call(AllTypes allTypes) {
}
});
subscription.unsubscribe();
assertTrue(realm.isClosed());
}
Aggregations