Structure

Result.Publisher

A Combine publisher that publishes a result and then finishes normally, or fails without publishing any elements.

Declaration

struct Publisher

Overview

If result is Result.success(_:), then this publisher waits until it receives a request for at least one value before sending the output. If result is Result.failure(_:), then this publisher sends the failure immediately upon subscription.

In contrast with Just, a result publisher can terminate with an error instead of sending a value. In contrast with Optional.Publisher, a result publisher always sends one value, unless it terminates with an error.

Topics

Type Aliases

typealias Result.Publisher.Output

The kind of values published by this publisher.

Initializers

init(Result<Result<Success, Failure>.Publisher.Output, Failure>)

Creates a publisher that delivers the specified result.

init(Failure)

Creates a publisher that immediately terminates upon subscription with the given failure.

init(Result<Success, Failure>.Publisher.Output)

Creates a publisher that delivers the specified output and finishes normally.

Instance Properties

let result: Result<Success, Failure>

The result to deliver to each subscriber.

Instance Methods

func receive<S>(subscriber: S)

Implements the publisher protocol by accepting the subscriber if the result is success, or terminating with an error immediately if it’s failure.

Relationships

Conforms To