Publishers
extension Publishers
-
Converts a materialized publisher of
Signal
s into the represented sequence. Fails on a malformed source sequence.Use this operator to convert a stream of
Signal
values from an upstream publisher into its materially represented publisher type. Malformed sequences will fail with aDematerializationError
.For each element:
.subscription
elements are ignored.input(_)
elements are unwrapped and forwarded to the subscriber.completion(_)
elements are forwarded within theDematerializationError
wrapper
If the integrity of the upstream sequence can be guaranteed, applying the
See moreassertNoDematerializationFailure()
operator to this publisher will force unwrap any errors and produce a publisher with aFailure
type that matches the materially represented original sequence.Declaration
Swift
public struct Dematerialize<Upstream> : Publisher where Upstream : Publisher, Upstream.Output : SignalConvertible
-
Automates the process of connecting to a multicast publisher. Connects when the first subscriber connects then cancels and discards when the subscriber count falls to zero.
See moreDeclaration
Swift
public final class ReferenceCounted<Upstream: Publisher, SubjectType: Subject>: Publisher where Upstream.Output == SubjectType.Output, Upstream.Failure == SubjectType.Failure
-
Configuration values for the
Publishers.Signpost
operator.Pass
Publishers.SignpostConfiguration.Marker
values to the initializer to define how signposts for each event should be labelled:- A nil marker value will disable signposts for that event
- A
.default
marker value will use the event name as the event label - A
.named(_:)
marker value will use the passed string as the event label
Declaration
Swift
public struct SignpostConfiguration
-
A publisher that combines the latest value from another publisher with each value from an upstream publisher
See moreDeclaration
Swift
public struct WithLatestFrom<Upstream, Other, Output> : Publisher where Upstream : Publisher, Other : Publisher, Upstream.Failure == Other.Failure
-
Creates a simple publisher inline from a provided closure
This publisher can be used to turn any arbitrary source of values (such as a timer or a user authorization request) into a new publisher sequence.
From within the scope of the closure passed into the initializer, it is possible to call the methods of the
Dispatcher
object – which is passed in as a parameter – to send values down stream.Example
import Entwine let photoKitAuthorizationStatus = Publishers.Factory<PHAuthorizationStatus, Never> { dispatcher in let status = PHPhotoLibrary.authorizationStatus() dispatcher.forward(status) switch status { case .notDetermined: PHPhotoLibrary.requestAuthorization { newStatus in dispatcher.forward(newStatus) dispatcher.forward(completion: .finished) } default: dispatcher.forward(completion: .finished) } return AnyCancellable {} }
Warning
Developers should be aware that aDispatcher
has an unbounded buffer that stores values yet to be requested by the downstream subscriber.When creating a publisher from a source with an unbounded rate of production that cannot be influenced, developers should consider following this operator with a
See morePublishers.Buffer
operator to prevent a strain on resourcesDeclaration
Swift
public struct Factory<Output, Failure> : Publisher where Failure : Error