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
Constructors -
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.abstract voidBeing called by heartbeat when value has been changed
-
Field Details
-
depends
-
-
Constructor Details
-
Watcher
Constructs a new instance- Parameters:
depends- parent state
-
-
Method Details
-
heartbeat
public void heartbeat()Trigger a heartbeat on this instance. If the value of the underlying observable has changed, trigger the action. -
onChange
Being called by heartbeat when value has been changed- Parameters:
newValue- the new value that has been set to it
-
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
-