SerialHook

public class SerialHook<T> : Hook where T : HookAction

This hook accepts many closures and invokes them serial in the current queue.

  • The type defining valid raw values for keys.

    Declaration

    Swift

    public typealias Action = T
  • Undocumented

    Declaration

    Swift

    public init()
  • Adds a closure for the given key.

    Declaration

    Swift

    public func respond<A, R>(to event: HookEvent<Action, 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.

    Return Value

    A weak referenced object that holds the closure.

  • Performs all closures for the given key.

    Declaration

    Swift

    @discardableResult
    public func trigger<A, R>(event: HookEvent<Action, A, R>, with argument: A) -> [R]

    Parameters

    event

    The hook event with the appropriate type information. Should be save statically.

    arguments

    The arguments passed for each closure for the given hook key.

    Return Value

    Returns all mapped values. If a conflicting hook key is used an empty array will be returned.