Package net.apartium.cocoabeans.state
Class Watcher<T>
java.lang.Object
net.apartium.cocoabeans.state.Watcher<T>
- Type Parameters:
T- element type
- All Implemented Interfaces:
Observer
- Direct Known Subclasses:
AttachedWatcher
An observer implementation attaching an action to an observable instance, performing it when its state changes and a heartbeat is triggered
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWatcher(Observable<T> depends, Consumer<T> consumer) Constructs a new instance -
Method Summary
Modifier and TypeMethodDescriptionvoiddetach()Detaches the current watcher from its target observable.voidflagAsDirty(Observable<?> observable) Flag listener as dirtyvoidTrigger a heartbeat on this instance.
-
Field Details
-
depends
-
-
Constructor Details
-
Watcher
Constructs a new instance- Parameters:
depends- parent stateconsumer- action to perform on change
-
-
Method Details
-
heartbeat
public void heartbeat()Trigger a heartbeat on this instance. If the value of the underlying observable has changed, trigger the action. -
detach
public void detach()Detaches the current watcher from its target observable. -
flagAsDirty
Flag listener as dirty- Specified by:
flagAsDirtyin interfaceObserver- Parameters:
observable- marking observable
-