Instance Method

tryPrefix(while:)

Republishes elements while a error-throwing predicate closure indicates publishing should continue.

Declaration

func tryPrefix(while predicate: @escaping (Upstream.Output) throws -> Bool) -> Publishers.TryPrefixWhile<Publishers.Output<Upstream>>

Parameters

predicate

A closure that takes an element as its parameter and returns a Boolean value indicating whether publishing should continue.

Return Value

A publisher that passes through elements until the predicate throws or indicates publishing should finish.

Discussion

The publisher finishes when the closure returns false. If the closure throws, the publisher fails with the thrown error.