Instance Method

contains(_:)

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

Declaration

func contains(_ output: Upstream.Output) -> Publishers.Contains<Publishers.Multicast<Upstream, SubjectType>>
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.