TokenizedOutputLiveCallbackRegistry
An auto-releasing registry of LiveCallbackContainers that correlates callbacks and its origins.
It respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures the registered callbacks are only invoked when appropriate.
You can register a callback paired with an object that implements the LifecycleOwner interface. This relationship allows the callback to be released when the state of the lifecycle changes to DESTROYED. This is especially useful for activities and fragments because they can safely register callbacks and not worry about leaks: the callback and lifecycle are instantly released when their lifecycles are destroyed.
Registered callbacks can be invoked when appropriate, given that an OutputCallbackToken corresponding to the one returned by register is provided on invoke.
This is meant to be used with callbacks that receive no parameters and return a value. For other kinds of callbacks, there are more specific versions:
TokenizedLiveCallbackRegistry: for callbacks that receive a parameter and return a value.
TokenizedInputLiveCallbackRegistry: for callbacks that receive a parameter and return no value.
TokenizedSimpleLiveCallbackRegistry: for callbacks that receive no parameters and return no value.
Parameters
The type of return of the callbacks.
Constructors
Creates an empty registry that relays invocations to the registered callbacks based on the provided OutputCallbackTokens.