Instance Method

prefix(while:)

Republishes elements while a predicate closure indicates publishing should continue.

Declaration

func prefix(while predicate: @escaping (Upstream.Output) -> Bool) -> Publishers.PrefixWhile<Publishers.TryComparison<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 indicates publishing should finish.

Discussion

The publisher finishes when the closure returns false.