Class RealmObservableFactory
- java.lang.Object
-
- io.realm.rx.RealmObservableFactory
-
- All Implemented Interfaces:
RxObservableFactory
public class RealmObservableFactory extends Object implements RxObservableFactory
Factory class for creating Observables for RxJava (<=2.0.*).
-
-
Constructor Summary
Constructors Constructor Description RealmObservableFactory(boolean emitFrozenObjects)
Constructs the factory for creating Realm observables for RxJava.
-
Method Summary
-
-
-
Constructor Detail
-
RealmObservableFactory
public RealmObservableFactory(boolean emitFrozenObjects)
Constructs the factory for creating Realm observables for RxJava.- Parameters:
emitFrozenObjects
-true
if all objects should be frozen before being returned to the user.false
if they should be live objects.
-
-
Method Detail
-
from
public Flowable<Realm> from(Realm realm)
Description copied from interface:RxObservableFactory
Creates a Flowable for aRealm
. It should emit the initial state of the Realm when subscribed to and on each subsequent update of the Realm.Realm flowables are hot as Realms are automatically kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-Realm
to listen to changes for.- Returns:
- Rx observable that emit all updates to the Realm.
-
from
public Flowable<DynamicRealm> from(DynamicRealm realm)
Description copied from interface:RxObservableFactory
Creates a Flowable for aDynamicRealm
. It should emit the initial state of the Realm when subscribed to and on each subsequent update of the Realm.DynamicRealm observables are hot as DynamicRealms are automatically kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-DynamicRealm
to listen to changes for.- Returns:
- Rx observable that emit all updates to the DynamicRealm.
-
from
public <E> Flowable<RealmResults<E>> from(Realm realm, RealmResults<E> results)
Description copied from interface:RxObservableFactory
Creates a Flowable for aRealmResults
. It should emit the initial RealmResult when subscribed to and on each subsequent update of the RealmResults.RealmResults observables are hot as RealmResults are automatically kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Type Parameters:
E
- type of RealmObject- Parameters:
realm
-Realm
instance results are coming from.results
-RealmResults
to listen to changes for.- Returns:
- Rx observable that emit all updates to the RealmObject.
-
changesetsFrom
public <E> Observable<CollectionChange<RealmResults<E>>> changesetsFrom(Realm realm, RealmResults<E> results)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmResults
. It should emit the initial RealmResult when subscribed to and on each subsequent update of the RealmResults it should emit the RealmResults + theOrderedCollectionChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefor be left to users.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Type Parameters:
E
- type of RealmObject- Parameters:
realm
-Realm
instance results are coming from.results
-RealmResults
to listen to changes for.- Returns:
- Rx observable that emit all updates + their changeset.
-
from
public <E> Flowable<RealmResults<E>> from(DynamicRealm realm, RealmResults<E> results)
Description copied from interface:RxObservableFactory
Creates a Flowable for aRealmResults
. It should emit the initial RealmResult when subscribed to and on each subsequent update of the RealmResults.Realm observables are hot as RealmResults are automatically kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-DynamicRealm
instance results are coming from.results
-RealmResults
to listen to changes for.- Returns:
- Rx observable that emit all updates to the RealmResults.
-
changesetsFrom
public <E> Observable<CollectionChange<RealmResults<E>>> changesetsFrom(DynamicRealm realm, RealmResults<E> results)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmResults
. It should emit the initial RealmResult when subscribed to and on each subsequent update of the RealmResults it should emit the RealmResults + theOrderedCollectionChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefor be left to users.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Parameters:
realm
-Realm
instance results are coming from.results
-RealmResults
to listen to changes for.- Returns:
- Rx observable that emit all updates + their changeset.
-
from
public <E> Flowable<RealmList<E>> from(Realm realm, RealmList<E> list)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmList
. It should emit the initial list when subscribed to and on each subsequent update of the RealmList.RealmList observables are hot as RealmLists are automatically kept up to date.
Note:
RealmChangeListener
is currently not supported on RealmLists.- Specified by:
from
in interfaceRxObservableFactory
- Type Parameters:
E
- type of query target- Parameters:
realm
-Realm
instance list is coming from.list
- RealmObject to listen to changes for.
-
changesetsFrom
public <E> Observable<CollectionChange<RealmList<E>>> changesetsFrom(Realm realm, RealmList<E> list)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmList
. It should emit the initial RealmList when subscribed to and on each subsequent update of the RealmIst it should emit the RealmList + theOrderedCollectionChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefor be left to users.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Type Parameters:
E
- type of RealmObject- Parameters:
realm
-Realm
instance list is coming from.list
-RealmList
to listen to changes for.- Returns:
- Rx observable that emit all updates + their changeset.
-
from
public <E> Flowable<RealmList<E>> from(DynamicRealm realm, RealmList<E> list)
Description copied from interface:RxObservableFactory
Creates a Flowable for aRealmList
. It should emit the initial list when subscribed to and on each subsequent update of the RealmList.RealmList observables are hot as RealmLists are automatically kept up to date.
Note:
RealmChangeListener
is currently not supported on RealmLists.- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-DynamicRealm
instance list is coming from.list
- RealmList to listen to changes for.
-
changesetsFrom
public <E> Observable<CollectionChange<RealmList<E>>> changesetsFrom(DynamicRealm realm, RealmList<E> list)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmList
. It should emit the initial RealmList when subscribed to and on each subsequent update of the RealmList it should emit the RealmList + theOrderedCollectionChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefor be left to users.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Parameters:
realm
-Realm
instance list is coming from.list
-RealmList
to listen to changes for.- Returns:
- Rx observable that emit all updates + their changeset.
-
from
public <E extends RealmModel> Flowable<E> from(Realm realm, E object)
Description copied from interface:RxObservableFactory
Creates a Flowable for aRealmObject
. It should emit the initial object when subscribed to and on each subsequent update of the object.RealmObject observables are hot as RealmObjects are automatically kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Type Parameters:
E
- type of query target- Parameters:
realm
-Realm
instance object is coming from.object
- RealmObject to listen to changes for.
-
changesetsFrom
public <E extends RealmModel> Observable<ObjectChange<E>> changesetsFrom(Realm realm, E object)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmObject
. It should emit the initial object when subscribed to and on each subsequent update of the object it should emit the object + theObjectChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefore be left to the user.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Type Parameters:
E
- type of RealmObject- Parameters:
realm
-Realm
instance object is coming from.object
- RealmObject to listen to changes for.
-
from
public Flowable<DynamicRealmObject> from(DynamicRealm realm, DynamicRealmObject object)
Description copied from interface:RxObservableFactory
Creates a Flowable for aDynamicRealmObject
. It should emit the initial object when subscribed to and on each subsequent update of the object.DynamicRealmObject observables are hot as DynamicRealmObjects automatically are kept up to date.
- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-DynamicRealm
instance object is coming from.object
- DynamicRealmObject to listen to changes for.
-
changesetsFrom
public Observable<ObjectChange<DynamicRealmObject>> changesetsFrom(DynamicRealm realm, DynamicRealmObject object)
Description copied from interface:RxObservableFactory
Creates an Observable for aRealmObject
. It should emit the initial object when subscribed to and on each subsequent update of the object it should emit the object + theObjectChangeSet
that describes the update.Changeset observables do not support backpressure as a changeset depends on the state of the previous changeset. Handling backpressure should therefore be left to the user.
- Specified by:
changesetsFrom
in interfaceRxObservableFactory
- Parameters:
realm
-Realm
instance object is coming from.object
- RealmObject to listen to changes for.
-
from
public <E> Single<RealmQuery<E>> from(Realm realm, RealmQuery<E> query)
Description copied from interface:RxObservableFactory
Creates a Single from aRealmQuery
. It should emit the query and then complete.A RealmQuery observable is cold.
- Specified by:
from
in interfaceRxObservableFactory
- Type Parameters:
E
- type of query target- Parameters:
realm
-Realm
instance query is coming from.query
- RealmQuery to emit.
-
from
public <E> Single<RealmQuery<E>> from(DynamicRealm realm, RealmQuery<E> query)
Description copied from interface:RxObservableFactory
Creates a Single from aRealmQuery
. It should emit the query and then complete.A RealmQuery observable is cold.
- Specified by:
from
in interfaceRxObservableFactory
- Parameters:
realm
-DynamicRealm
instance query is coming from.query
- RealmObject to listen to changes for.
-
-