Publishes a Boolean value upon receiving an element that satisfies the throwing predicate closure.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Combine
Declaration
func tryContains(where predicate: @escaping (DeferredPublisher.Output) throws -> Bool) -> Publishers.Try Contains Where<Deferred<DeferredPublisher>>
Parameters
predicate
A closure that takes an element as its parameter and returns a Boolean value indicating whether the element satisfies the closure’s comparison logic.
Return Value
A publisher that emits the Boolean value true
when the upstream publisher emits a matching value.
Discussion
This operator consumes elements produced from the upstream publisher until the upstream publisher produces a matching element. If the closure throws, the stream fails with an error.