Instance Method

contains(_:)

Publishes a Boolean value upon receiving an element equal to the argument.

Declaration

func contains(_ output: Upstream.Output) -> Publishers.Contains<Publishers.Share<Upstream>>
Available when Output conforms to Equatable.

Parameters

output

An element to match against.

Return Value

A publisher that emits the Boolean value true when the upstream publisher emits a matching value.

Discussion

The contains publisher consumes all received elements until the upstream publisher produces a matching element. At that point, it emits true and finishes normally. If the upstream finishes normally without producing a matching element, this publisher emits false, then finishes.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software