Class LazyWatcher<T>

java.lang.Object
net.apartium.cocoabeans.state.LazyWatcher<T>
Type Parameters:
T - T as type
All Implemented Interfaces:
Observer

@AvailableSince("0.0.41") public class LazyWatcher<T> extends Object implements Observer
Watcher implementation that contains the last manually updated value. Updating the value occurs through the getOrUpdate() method
  • Method Details

    • create

      public static <T> LazyWatcher<T> create(Observable<T> observable)
    • flagAsDirty

      public void flagAsDirty(Observable<?> observable)
      Description copied from interface: Observer
      Flag listener as dirty
      Specified by:
      flagAsDirty in interface Observer
      Parameters:
      observable - marking observable
    • setDependsOn

      public void setDependsOn(Observable<T> dependsOn)
    • isDirty

      public boolean isDirty()
    • getLastValue

      public T getLastValue()
      Get the value applied from last getOrUpdate() call.
      Returns:
      last applied value
    • getOrUpdate

      public net.apartium.cocoabeans.structs.Entry<T,Boolean> getOrUpdate()
      If the current watcher is dirty, update it if necessary, then return the new value.
      Returns:
      entry containing the up-to-date value (key) and if it was changed since previous call (value).
    • delete

      public void delete()
    • getWatchedObservable

      public Observable<T> getWatchedObservable()