Instance Method


Republishes elements while a predicate closure indicates publishing should continue.


func prefix(while predicate: @escaping (Upstream.Output) -> Bool) -> Publishers.PrefixWhile<Publishers.Share<Upstream>>



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.


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