DelegationHook
public class DelegationHook<T> : Hook where T : HookAction
Hook with from 0 to 1 closures per hook key. An array of return values will be returned.
-
Undocumented
Declaration
Swift
public typealias Action = T
-
Undocumented
Declaration
Swift
public init()
-
Adds a closure for the given key.
Declaration
Swift
@discardableResult public func respond<A, R>(to event: HookEvent<T, A, R>, with action: @escaping (A) -> R) -> AnyObject?
Parameters
event
The hook key with the appropriate type information. Should be save statically.
closure
The closure to be performed when the hook key will be performed.
-
Performs all closures for the given key.
Declaration
Swift
@discardableResult public func trigger<A, R>(event: HookEvent<T, A, R>, with argument: A) -> [R]
Parameters
event
The hook key with the appropriate type information. Should be save statically.
arguments
The arguments passed for each closure for the given hook key.
Return Value
Returns the mapped value if closure is available.