/// A publisher that never publishes any values, and optionally finishes immediately. /// /// You can create a ”Never” publisher — one which never sends values and never finishes or fails — with the initializer `Empty(completeImmediately: false)`. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) publicstructEmpty<Output, Failure> : Publisher, EquatablewhereFailure : Error{
/// Creates an empty publisher. /// /// - Parameter completeImmediately: A Boolean value that indicates whether the publisher should immediately finish. publicinit(completeImmediately: Bool = true)
/// Creates an empty publisher with the given completion behavior and output and failure types. /// /// Use this initializer to connect the empty publisher to subscribers or other publishers that have specific output and failure types. /// /// - Parameters: /// - completeImmediately: A Boolean value that indicates whether the publisher should immediately finish. /// - outputType: The output type exposed by this publisher. /// - failureType: The failure type exposed by this publisher. publicinit(completeImmediately: Bool = true, outputType: Output.Type, failureType: Failure.Type)
/// A Boolean value that indicates whether the publisher immediately sends a completion. /// /// If `true`, the publisher finishes immediately after sending a subscription to the subscriber. If `false`, it never completes. publiclet completeImmediately: Bool
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereOutput == S.Input, Failure == S.Failure, S : Subscriber
/// Returns a Boolean value that indicates whether two publishers are equivalent. /// - Parameters: /// - lhs: An `Empty` instance to compare. /// - rhs: Another `Empty` instance to compare. /// - Returns: `true` if the two publishers have equal `completeImmediately` properties; otherwise `false`. publicstaticfunc == (lhs: Empty<Output, Failure>, rhs: Empty<Output, Failure>) -> Bool }
/// A publisher that emits an output to each subscriber just once, and then finishes. /// /// You can use a ``Just`` publisher to start a chain of publishers. A ``Just`` publisher is also useful when replacing a value with ``Publishers/Catch``. /// /// In contrast with <doc://com.apple.documentation/documentation/Swift/Result/Publisher>, a ``Just`` publisher can’t fail with an error. And unlike <doc://com.apple.documentation/documentation/Swift/Optional/Publisher>, a ``Just`` publisher always produces a value. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) publicstructJust<Output> : Publisher{
/// The kind of errors this publisher might publish. /// /// Use `Never` if this `Publisher` does not publish errors. publictypealiasFailure = Never
/// The one element that the publisher emits. publiclet output: Output
/// Initializes a publisher that emits the specified output just once. /// /// - Parameter output: The one element that the publisher emits. publicinit(_ output: Output)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereOutput == S.Input, S : Subscriber, S.Failure == Just<Output>.Failure }
/// A publisher that eventually produces a single value and then finishes or fails. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) finalpublicclassFuture<Output, Failure> : PublisherwhereFailure : Error{
/// A type that represents a closure to invoke in the future, when an element or error is available. /// /// The promise closure receives one parameter: a `Result` that contains either a single element published by a ``Future``, or an error. publictypealiasPromise = (Result<Output, Failure>) -> Void
/// Creates a publisher that invokes a promise closure when the publisher emits an element. /// /// - Parameter attemptToFulfill: A ``Future/Promise`` that the publisher invokes when the publisher emits an element or terminates with an error. publicinit(_ attemptToFulfill: @escaping (@escaping Future<Output, Failure>.Promise) -> Void)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. finalpublicfuncreceive<S>(subscriber: S)whereOutput == S.Input, Failure == S.Failure, S : Subscriber }
/// A publisher that awaits subscription before running the supplied closure to create a publisher for the new subscriber. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) publicstructDeferred<DeferredPublisher> : PublisherwhereDeferredPublisher : Publisher{
/// The kind of values published by this publisher. publictypealiasOutput = DeferredPublisher.Output
/// The kind of errors this publisher might publish. publictypealiasFailure = DeferredPublisher.Failure
/// The closure to execute when this deferred publisher receives a subscription. /// /// The publisher returned by this closure immediately receives the incoming subscription. publiclet createPublisher: () -> DeferredPublisher
/// Creates a deferred publisher. /// /// - Parameter createPublisher: The closure to execute when calling `subscribe(_:)`. publicinit(createPublisher: @escaping () -> DeferredPublisher)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereS : Subscriber, DeferredPublisher.Failure == S.Failure, DeferredPublisher.Output == S.Input }
/// A publisher that immediately terminates with the specified error. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) publicstructFail<Output, Failure> : PublisherwhereFailure : Error{
/// Creates a publisher that immediately terminates with the specified failure. /// /// - Parameter error: The failure to send when terminating the publisher. publicinit(error: Failure)
/// Creates publisher with the given output type, that immediately terminates with the specified failure. /// /// Use this initializer to create a `Fail` publisher that can work with subscribers or publishers that expect a given output type. /// /// - Parameters: /// - outputType: The output type exposed by this publisher. /// - failure: The failure to send when terminating the publisher. publicinit(outputType: Output.Type, failure: Failure)
/// The failure to send when terminating the publisher. publiclet error: Failure
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereOutput == S.Input, Failure == S.Failure, S : Subscriber }
/// A publisher that publishes a given sequence of elements. /// /// When the publisher exhausts the elements in the sequence, the next request causes the publisher to finish. publicstructSequence<Elements, Failure> : PublisherwhereElements : Sequence, Failure : Error{
/// The kind of values published by this publisher. publictypealiasOutput = Elements.Element
/// The sequence of elements to publish. publiclet sequence: Elements
/// Creates a publisher for a sequence of elements. /// /// - Parameter sequence: The sequence of elements to publish. publicinit(sequence: Elements)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereFailure == S.Failure, S : Subscriber, Elements.Element == S.Input } }
/// A publisher that allows for recording a series of inputs and a completion, for later playback to each subscriber. @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) publicstructRecord<Output, Failure> : PublisherwhereFailure : Error{
/// The recorded output and completion. publiclet recording: Record<Output, Failure>.Recording
/// Creates a publisher to interactively record a series of outputs and a completion. /// /// - Parameter record: A recording instance that can be retrieved after completion to create new record publishers to replay the recording. publicinit(record: (inoutRecord<Output, Failure>.Recording) -> Void)
/// Creates a record publisher from an existing recording. /// /// - Parameter recording: A previously-recorded recording of published elements and a completion. publicinit(recording: Record<Output, Failure>.Recording)
/// Creates a record publisher to publish the provided elements, followed by the provided completion value. /// /// - Parameters: /// - output: An array of output elements to publish. /// - completion: The completion value with which to end publishing. publicinit(output: [Output], completion: Subscribers.Completion<Failure>)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. publicfuncreceive<S>(subscriber: S)whereOutput == S.Input, Failure == S.Failure, S : Subscriber
/// A recorded sequence of outputs, followed by a completion value. publicstructRecording{
publictypealiasInput = Output
/// The output which will be sent to a `Subscriber`. publicvar output: [Output] { get }
/// The completion which will be sent to a `Subscriber`. publicvar completion: Subscribers.Completion<Failure> { get }
/// Set up a recording in a state ready to receive output. publicinit()
/// Set up a complete recording with the specified output and completion. publicinit(output: [Output], completion: Subscribers.Completion<Failure> = .finished)
/// Add an output to the recording. /// /// A `fatalError` will be raised if output is added after adding completion. publicmutatingfuncreceive(_ input: Record<Output, Failure>.Recording.Input)
/// Add a completion to the recording. /// /// A `fatalError` will be raised if more than one completion is added. publicmutatingfuncreceive(completion: Subscribers.Completion<Failure>) } }
/// A publisher that shares the output of an upstream publisher with multiple subscribers. /// /// This publisher type supports multiple subscribers, all of whom receive unchanged elements and completion states from the upstream publisher. /// /// > Tip: ``Publishers/Share`` is effectively a combination of the ``Publishers/Multicast`` and ``PassthroughSubject`` publishers, with an implicit ``ConnectablePublisher/autoconnect()``. /// /// Be aware that ``Publishers/Share`` is a class rather than a structure like most other publishers. Use this type when you need a publisher instance that uses reference semantics. finalpublicclassShare<Upstream> : Publisher, EquatablewhereUpstream : Publisher{
/// The kind of values published by this publisher. /// /// This publisher uses its upstream publisher's output type. publictypealiasOutput = Upstream.Output
/// The kind of errors this publisher might publish. /// /// This publisher uses its upstream publisher's failure type. publictypealiasFailure = Upstream.Failure
/// The publisher from which this publisher receives elements. finalpubliclet upstream: Upstream
/// Creates a publisher that shares the output of an upstream publisher with multiple subscribers. /// - Parameter upstream: The publisher from which this publisher receives elements. publicinit(upstream: Upstream)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. finalpublicfuncreceive<S>(subscriber: S)whereS : Subscriber, Upstream.Failure == S.Failure, Upstream.Output == S.Input
/// Returns a Boolean value that indicates whether two publishers are equivalent. /// - Parameters: /// - lhs: A `Share` publisher to compare for equality. /// - rhs: Another `Share` publisher to compare for equality. /// - Returns: `true` if the publishers have reference equality (`===`); otherwise `false`. publicstaticfunc == (lhs: Publishers.Share<Upstream>, rhs: Publishers.Share<Upstream>) -> Bool }
/// A publisher that uses a subject to deliver elements to multiple subscribers. /// /// Use a multicast publisher when you have multiple downstream subscribers, but you want upstream publishers to only process one ``Subscriber/receive(_:)`` call per event. finalpublicclassMulticast<Upstream, SubjectType> : ConnectablePublisherwhereUpstream : Publisher, SubjectType : Subject, Upstream.Failure == SubjectType.Failure, Upstream.Output == SubjectType.Output{
/// The kind of values published by this publisher. /// /// This publisher uses its upstream publisher's output type. publictypealiasOutput = Upstream.Output
/// The kind of errors this publisher might publish. /// /// This publisher uses its upstream publisher's failure type. publictypealiasFailure = Upstream.Failure
/// The publisher from which this publisher receives its elements. finalpubliclet upstream: Upstream
/// A closure that returns a subject each time a subscriber attaches to the multicast publisher. finalpubliclet createSubject: () -> SubjectType
/// Creates a multicast publisher that applies a closure to create a subject that delivers elements to subscribers. /// /// - Parameter createSubject: A closure that returns a ``Subject`` each time a subscriber attaches to the multicast publisher. publicinit(upstream: Upstream, createSubject: @escaping () -> SubjectType)
/// Attaches the specified subscriber to this publisher. /// /// Implementations of ``Publisher`` must implement this method. /// /// The provided implementation of ``Publisher/subscribe(_:)-4u8kn``calls this method. /// /// - Parameter subscriber: The subscriber to attach to this ``Publisher``, after which it can receive values. finalpublicfuncreceive<S>(subscriber: S)whereS : Subscriber, SubjectType.Failure == S.Failure, SubjectType.Output == S.Input
/// Connects to the publisher, allowing it to produce elements, and returns an instance with which to cancel publishing. /// /// - Returns: A ``Cancellable`` instance that you use to cancel publishing. finalpublicfuncconnect() -> Cancellable }