Signal
public final class Signal<Event>
Signal provides a mechanism for publishing events to subscribers.
-
Initializes a
Signal.Declaration
Swift
public init() -
Emits
selfto all subscribers.Declaration
Swift
public func emit(_ event: Event) -
Subscribes an object to
self.The subscription will be automatically cancelled when the owner is deallocated. The action will be delivered asynchronously on the specified queue.
Declaration
Swift
public func subscribe(owner: AnyObject, in queue: DispatchQueue = default, action: @escaping (Event) -> Void)Parameters
ownersubscription owner.
queueDispatchQueueto use when invoking the action, defaults to the main queue.actionclosure to invoke when the signal is emitted.
-
Unsubscribes an object from
self.Declaration
Swift
public func unsubscribe(_ owner: AnyObject)Parameters
ownersubscription owner.
-
Removes all subscribers.
Declaration
Swift
public func unsubscribeAll() -
Creates a new signal that filters events from this signal.
Declaration
Swift
public func filter(where eval: @escaping (Event) -> Bool) -> Signal<Event> -
Returns a new signal that emits mapped event.
Declaration
Swift
public func map<T>(_ f: @escaping (Event) -> T) -> Signal<T> -
Returns a new signal that emits mapped events and skips
nilevents.Declaration
Swift
public func flatMap<T>(_ f: @escaping (Event) -> T?) -> Signal<T>
View on GitHub
Signal Class Reference