Republishes elements while a predicate closure indicates publishing should continue.
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
A closure that takes an element as its parameter and returns a Boolean value indicating whether publishing should continue.
A publisher that passes through elements until the predicate indicates publishing should finish.
prefix(while:) to emit values while elements from the upstream publisher meet a condition you specify. The publisher finishes when the closure returns
In the example below, the
prefix(while:) operator emits values while the element it receives is less than five: