Event

public class Event<T>

A class that implements event pattern that enables signalling of an event occurs.

  • Alias for a closure that takes the event data payload type and do something with it

    Declaration

    Swift

    public typealias EventHandler = (T) -> ()
  • Raise an signal to the list of handlers added to this event.

    Declaration

    Swift

    public func raise(data: T)

    Parameters

    data

    payload to send to the handlers via this signal

  • Add a listener to handle the signal raised by an Event object

    Declaration

    Swift

    public func addHandler<U: AnyObject>(target: U,
                                         handler: @escaping (U) -> EventHandler) -> Disposable

    Parameters

    target

    object reference that subscribe to the event

    handler

    the handler to handle the event