Package arez.component
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 Summary
Modifier and TypeMethodDescriptionvoid
addOnDisposeListener
(Object key, SafeProcedure action) Add the listener to notify list under key.static DisposeNotifier
asDisposeNotifier
(Object object) Cast the specified object to an instance of DisposeNotifier.void
Remove the listener with specified key from the notify list.
-
Method Details
-
addOnDisposeListener
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
andDisposable.isDisposed()
returnstrue
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 involvingCascadeDispose
.- Parameters:
key
- the key to uniquely identify listener.action
- the listener callback.
-
removeOnDisposeListener
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 usingaddOnDisposeListener(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
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.
-