Instance Method

prefix(while:)

Republishes elements while a predicate closure indicates publishing should continue.

Declaration

func prefix(while predicate: @escaping (Prefix.Output) -> Bool) -> Publishers.PrefixWhile<Publishers.Concatenate<Prefix, Suffix>>

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 indicates publishing should finish.

Discussion

The publisher finishes when the closure returns false.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software