Dispatcher
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public class Dispatcher<Input, Failure> where Failure : Error
Manages a queue of publisher sequence elements to be delivered to a subscriber
-
Queues an element to be delivered to the subscriber
Warning
If either the
forward(completion:)
or theforwardImmediately(completion:)
method of the dispatcher has already been called this will raise an assertion failure.Declaration
Swift
public func forward(_ input: Input)
Parameters
input
a value to be delivered to a downstream subscriber
-
Completes the sequence once any queued elements are delivered to the subscriber
Warning
If either the
forward(completion:)
or theforwardImmediately(completion:)
method of the dispatcher has already been called this will raise an assertion failure.Declaration
Swift
public func forward(completion: Subscribers.Completion<Failure>)
Parameters
completion
a completion value to be delivered to the subscriber once the remaining items in the queue have been delivered
-
Completes the sequence immediately regardless of any elements that are waiting to be delivered
Warning
subsequent calls to the dispatcher will raise an assertion failureDeclaration
Swift
public func forwardImmediately(completion: Subscribers.Completion<Failure>)
Parameters
completion
a completion value to be delivered immediately to the subscriber