Publishes a Boolean value upon receiving an element equal to the argument.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Combine
Declaration
func contains(_ output: Upstream.Output) -> Publishers.Contains<Publishers.Autoconnect<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.