CallbackRegistry
public actor CallbackRegistry
A registry for managing Callback instances.
It holds a dictionary of registered Callback types and provides methods to create and manage them.
It is a singleton actor that can be accessed globally.
It allows for the registration of default Callbacks and the creation of Callback instances from a list of dictionaries.
It also provides a method to inject a ContinueNode into the Callbacks, allowing them to be aware of the Journey they are part of.
-
Thread-safe read-only access to the callbacks dictionary
Declaration
Swift
public var callbacks: [String : any Callback.Type] { get } -
The shared instance of the CallbackRegistry.
Declaration
Swift
public static let shared: CallbackRegistry -
Registers a new type of Callback.
Declaration
Swift
public func register(type: String, callback: any Callback.Type)Parameters
typeThe type of the Callback.
callbackThe concrete Callback metatype to register.
-
callback(from:Asynchronous) Creates a list of Callback instances from an array of dictionaries. Each dictionary should have a “type” field that matches a registered Callback type.
Declaration
Swift
public func callback(from array: [[String : any Sendable]]) async -> CallbacksParameters
arrayThe array of dictionaries to create the Callbacks from.
Return Value
A list of Callback instances (specialized metadata callbacks are filtered out).
-
Injects the ContinueNode and Journey instances into the callbacks that require them.
Declaration
Swift
public func inject(continueNode: ContinueNode, journey: Journey)Parameters
continueNodeThe ContinueNode instance to be injected.
journeyThe Journey workflow instance to be injected.
-
Resets the CallbackRegistry by clearing all registered callbacks.
Declaration
Swift
public func reset() -
Accessor for a registered metatype by key, used by MetadataCallback specialization.
Declaration
Swift
public func type(for key: String) -> (any Callback.Type)?Parameters
keyString
Return Value
A Callback type
View on GitHub