Interface DisposeNotifier


public interface DisposeNotifier
Interface implemented by a component if it supports notifying listeners when the component is disposed. This notification occurs using a call-back and occurs within the dispose transaction (after PreDispose is invoked if present) using a callback. Contrast this with the strategy used by ComponentObservable which uses standard Arez observables to track when a component is disposed.
  • Method Details

    • addOnDisposeListener

      void addOnDisposeListener(@Nonnull Object key, @Nonnull SafeProcedure action)
      Add the listener to notify list under key. This method MUST NOT be invoked after the component has been disposed. This method should not be invoked if another listener has been added with the same key without being removed.

      If the key implements Disposable and Disposable.isDisposed() returns true when invoking the calback then the callback will be skipped. This rare situation only occurs when there is circular dependency in the object model usually involving CascadeDispose.

      Parameters:
      key - the key to uniquely identify listener.
      action - the listener callback.
    • removeOnDisposeListener

      void removeOnDisposeListener(@Nonnull Object key)
      Remove the listener with specified key from the notify list. This method should only be invoked when a listener has been added for specific key using addOnDisposeListener(Object, SafeProcedure) and has not been removed by another call to this method.
      Parameters:
      key - the key under which the listener was previously added.
    • asDisposeNotifier

      @Nonnull static DisposeNotifier asDisposeNotifier(@Nonnull Object object)
      Cast the specified object to an instance of DisposeNotifier. Invariant checks will verify that the cast is valid before proceeding.
      Parameters:
      object - the object.
      Returns:
      the object cast to DisposeNotifier.