Bus
class Bus
A Bus for events to go from publishers to subscribers
-
A name for the bus.
Declaration
Swift
public private(set) var label: String { get } -
Queue on which to execute publish/subscribe actions to ensure thread safety
Declaration
Swift
public private(set) var queue: DispatchQueue { get } -
Initialize a Causality Event Bus
Declaration
Swift
public init(label: String, queue: DispatchQueue = globalQueue)Parameters
labelname to give the bus
queueQueue for bookkeeping (e.g. to ensure publish/subscribe is thread safe)
-
Publish an event to the bus.
All subscribers to this event will have their handler called along with the associated message.
Declaration
Parameters
eventEvent to publish
messageMessage to send in event
-
Add a subscriber to a specific event type
Declaration
Parameters
eventThe event 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 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)
-
Add a subscriber to an event
Declaration
Parameters
eventThe event 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)
Return Value
Subscription handle that is needed to unsubscribe to this event
-
Add a subscriber to an event
Declaration
Parameters
eventThe event 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)
Return Value
Subscription handle that is needed to unsubscribe to this event
-
Stop a particular subscription handler from listening to events anymore.
Declaration
Parameters
subsriptionThe Subscription that was returned from
subscribe()
-
Publish an event to the bus.
All subscribers to this event will have their handler called along with the associated message.
Declaration
Parameters
stateThe state to set the value for
valueThe value to set for the given state
-
Add a subscriber to a specific state type
Declaration
Parameters
stateThe state 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 state type
Declaration
Parameters
stateThe state 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)
-
Add a subscriber to a specific state type
Declaration
Parameters
stateThe state 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 state type
Declaration
Parameters
stateThe 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 state changes anymore.
Declaration
Parameters
subscriptionThe Subscription that was returned from
subscribe()
Bus Class Reference