Generic Instance Method

multicast(_:)

Applies a closure to create a subject that delivers elements to subscribers.

Declaration

func multicast<S>(_ createSubject: @escaping () -> S) -> Publishers.Multicast<Publishers.Concatenate<Prefix, Suffix>, S> where S : Subject, Self.Failure == S.Failure, Self.Output == S.Output

Parameters

createSubject

A closure to create a new Subject each time a subscriber attaches to the multicast publisher.

Discussion

Use a multicast publisher when you have multiple downstream subscribers, but you want upstream publishers to only process one receive(_:) call per event.

In contrast with multicast(subject:), this method produces a publisher that creates a separate Subject for each subscriber.