Class LifecycleHookHandler
Provides functionality to register, unregister, and invoke lifecycle hooks in a thread-safe manner.
public class LifecycleHookHandler
- Inheritance
-
LifecycleHookHandler
- Inherited Members
Constructors
LifecycleHookHandler()
public LifecycleHookHandler()
Methods
InvokeHooks(SwiftList<OrderedLifecycleHook>)
Invokes all registered lifecycle hooks in the order they were registered.
public void InvokeHooks(SwiftList<OrderedLifecycleHook> hooks)
Parameters
hooksSwiftList<OrderedLifecycleHook>The list of hooks to invoke.
RegisterHook(SwiftList<OrderedLifecycleHook>, string, int, Action)
Registers a lifecycle hook with the specified owner, order, and callback. Hooks are executed in order of their specified order, and if orders are equal, they are sorted by owner name. The returned IDisposable can be used to unregister the hook when it is no longer needed.
public IDisposable RegisterHook(SwiftList<OrderedLifecycleHook> hooks, string owner, int order, Action callback)
Parameters
hooksSwiftList<OrderedLifecycleHook>The list of hooks to register the new hook with.
ownerstringThe owner of the hook, used to identify and manage the hook.
orderintThe order in which the hook should be executed relative to other hooks.
callbackActionThe callback to invoke when the hook is executed.
Returns
- IDisposable
An IDisposable that can be used to unregister the hook.
Exceptions
- ArgumentException
Thrown if the owner is null or whitespace.
- InvalidOperationException
Thrown if a hook with the same owner is already registered.
UnregisterHook(SwiftList<OrderedLifecycleHook>, string)
Unregisters a lifecycle hook based on the specified owner.
public void UnregisterHook(SwiftList<OrderedLifecycleHook> hooks, string owner)
Parameters
hooksSwiftList<OrderedLifecycleHook>The list of hooks to unregister the hook from.
ownerstringThe owner of the hook to unregister.