Package io.objectbox.reactive
Class SubscriptionBuilder.ActionObserver
- java.lang.Object
-
- io.objectbox.reactive.SubscriptionBuilder.ActionObserver
-
- All Implemented Interfaces:
DataObserver<T>,DelegatingObserver<T>
- Enclosing class:
- SubscriptionBuilder<T>
class SubscriptionBuilder.ActionObserver extends java.lang.Object implements DataObserver<T>, DelegatingObserver<T>
Wraps aDataObserversupplied toSubscriptionBuilder.observer(DataObserver)to support result transformation, an error observer or scheduler for result delivery.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classSubscriptionBuilder.ActionObserver.SchedulerRunOnChange(package private) classSubscriptionBuilder.ActionObserver.SchedulerRunOnError
-
Field Summary
Fields Modifier and Type Field Description private SubscriptionBuilder.ActionObserver.SchedulerRunOnChangeschedulerRunOnDataprivate SubscriptionBuilder.ActionObserver.SchedulerRunOnErrorschedulerRunOnErrorprivate DataSubscriptionImplsubscription
-
Constructor Summary
Constructors Constructor Description ActionObserver(DataSubscriptionImpl subscription)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcallOnData(T data)private voidcallOnError(java.lang.Throwable th, java.lang.String msgNoErrorObserver)DataObserver<T>getObserverDelegate()voidonData(T data)Called when data changed.private voidtransformAndContinue(T data)Runs on the thread of theonData(Object)caller to ensure data is delivered in the same order asonData(Object)was called, to prevent delivering stale data.
-
-
-
Field Detail
-
subscription
private final DataSubscriptionImpl subscription
-
schedulerRunOnError
private SubscriptionBuilder.ActionObserver.SchedulerRunOnError schedulerRunOnError
-
schedulerRunOnData
private SubscriptionBuilder.ActionObserver.SchedulerRunOnChange schedulerRunOnData
-
-
Constructor Detail
-
ActionObserver
public ActionObserver(DataSubscriptionImpl subscription)
-
-
Method Detail
-
onData
public void onData(T data)
Description copied from interface:DataObserverCalled when data changed.Exception note: if this method throws an exception, it can be reacted on via
SubscriptionBuilder.onError(ErrorObserver).- Specified by:
onDatain interfaceDataObserver<T>
-
transformAndContinue
private void transformAndContinue(T data)
Runs on the thread of theonData(Object)caller to ensure data is delivered in the same order asonData(Object)was called, to prevent delivering stale data.For both ObjectClassPublisher and QueryPublisher this is the asynchronous thread publish requests are processed on.
This could be optimized in the future to allow parallel execution, but this would require an ordering mechanism for the transformed data.
-
callOnError
private void callOnError(java.lang.Throwable th, java.lang.String msgNoErrorObserver)
-
callOnData
void callOnData(T data)
-
getObserverDelegate
public DataObserver<T> getObserverDelegate()
- Specified by:
getObserverDelegatein interfaceDelegatingObserver<T>
-
-