Bus
class Bus
A Bus for events to go from publishers to subscribers
-
A name for the bus.
Declaration
Swift
public private(set) var name: String { get } -
Initialize a Causality Event Bus
Declaration
Swift
public init(name: String)Parameters
namename to give the bus
-
Subscription identifier used by subscribers to be able to unsubscribe.
Declaration
Swift
public typealias Subscription = UUID
-
Add a subscriber to a specific event type
Declaration
Parameters
eventThe event type to subscribe to.
handlerA handler that is called for each event of this type that occurs. This handler will be called on the queue specified by the publisher (if given). Otherwise there is no guarantee on what queue/thread the handler will be called on.
-
Add a subscriber to a specific event type
Declaration
Parameters
eventThe event type to subscribe to.
queueDispatchQueue to receive messages on. This will take precedence over any queue specified by the publisher.
handlerA handler that is called for each event of this type that occurs (on the specified queue)
-
Add a subscriber to a specific event type
Declaration
Parameters
eventThe event type to subscribe to.
queueOperationQueue to receive messages on. This will take precedence over any queue specified by the publisher.
handlerA handler that is called for each event of this type that occurs (on the specified queue)
-
Stop a particular subscription handler from listening to events anymore.
Declaration
Swift
public func unsubscribe(_ subscription: Subscription)Parameters
subsriptionThe Subscription that was returned from
subscribe() -
Unsubscribe an array of subscriptions
Declaration
Swift
public func unsubscribe(_ subscriptions: [Subscription])Parameters
subscriptionsSubscriptions to unsubscribe from
Bus Class Reference