Instance Method

first(where:)

Publishes the first element of a stream to satisfy a predicate closure, then finishes.

Declaration

func first(where predicate: @escaping ((A.Output, B.Output)) -> Bool) -> Publishers.FirstWhere<Publishers.CombineLatest<A, B>>

Parameters

predicate

A closure that takes an element as a parameter and returns a Boolean value that indicates whether to publish the element.

Return Value

A publisher that only publishes the first element of a stream that satifies the predicate.

Discussion

The publisher ignores all elements after the first. If this publisher doesn’t receive any elements, it finishes without publishing.