This is Understanding Combine, written by Matt Neuburg. Corrections and suggestions are greatly appreciated (you can comment here). So are donations; please consider keeping me going by funding this work at http://www.paypal.me/mattneub. Or buy my books: the current (and final) editions are iOS 15 Programming Fundamentals with Swift and Programming iOS 14. Thank you!
.drop(untilOutputFrom:)
(Publishers.DropUntilOutput) is not precisely a joiner; but it does involve input from two publishers, like a joiner, so it is more like a joiner than its .drop
cousins, which are clearly partitioners. Therefore I’m mentioning it here.
What .drop(untilOutputFrom:)
does is to cause all values from upstream to be suppressed, until some other publisher emits a value. That value is ignored, and the subscription to that other publisher is dropped — and the values from upstream are now permitted to flow down the pipeline.
Basically, this is a kind of switch (or gate), where a secondary publisher has the power to throw the switch (or open the gate) and allow values to flow. In that sense, it is a quite like .zip
and .combineLatest
, where nothing arrives downstream until both publishers have published.
The output type of the second publisher doesn’t matter; its value is a dummy signal and is disregarded.
If the second publisher emits a completion without having emitted a value, that completion propagates down the pipeline and the entire pipeline comes to an end without any value having come downstream from the first publisher. Thus the second publisher has the additional power of cancelling the entire pipeline before it ever gets going.
The complementary operator is .prefix(untilOutputFrom)
.