Event

public class Event<State>

Event representation class. You need to create an instance of event and then bind on it and trigger State is a generic parameter that specify a type of information that current event might send to listeners

  • true if current event have at least one listener

    Declaration

    Swift

    public var hasListeners: Bool { get }
  • Main initializer

    Declaration

    Swift

    public init()
  • Method that will trigger information notifying to all listeners

    Declaration

    Swift

    public func trigger(with state: State)

    Parameters

    state

    An information that needs to be send to listeners

  • Adding new listener to current event

    Declaration

    Swift

    @discardableResult
    public func listen(signedBy object: AnyObject? = nil) -> Listener<State>

    Parameters

    object

    Signing object. Might be only one subscription per one object. Useful if you want to be sure that you have not subscribed several times to similar event with one object

    Return Value

    Listener that might be additionaly configured

  • Removing listener signed with object

    Declaration

    Swift

    @discardableResult
    public func removeListener(signedBy: AnyObject) -> Bool

    Parameters

    signedBy

    Signing object

    Return Value

    true if listener was successfuly removed