MakeThreadSafe

public struct MakeThreadSafe<Upstream> : Publisher where Upstream : Publisher, Upstream.Output : ThreadConfined

A publisher which makes receive(on:) work for streams of thread-confined objects

Create using .threadSafeReference()

  • Specifies the scheduler on which to receive elements from the publisher.

    This publisher converts each value emitted by the upstream publisher to a ThreadSafeReference, passes it to the target scheduler, and then converts back to the original type.

    Declaration

    Swift

    public func receive<S>(on scheduler: S) -> DeferredHandover<Upstream, S> where S : Scheduler

    Parameters

    scheduler

    The serial dispatch queue to receive values on.

    Return Value

    A publisher which delivers values to the given scheduler.