Swift Combine: drop(untilOutputFrom: )

Let’s go ahead and take a look at drop(untilOutputFrom: ) filtering Operator.

So the operator in question is drop(untilOutputFrom: ) and it’s going to drop the events or the value from a sequence until it gets an output from another publisher.

It’s a little bit hard to understand.

drop(untilOutputFrom:)

I created a PassthroughSubject. When you put dot on the PassthroughSubject, you can find this method. .drop(untilOutputFrom: ). This method takes publisher as an argument. When isReady PassthroughSubject(Publisher) sends an event, then those values won’t be dropped.

Look at the (1...10) loop. the values in the loop are dropped. It never reaches sink() and (1...10) never gets access to those taps.

You can think of isReady publisher as a kind of giving a green flag, indicating that now it’s OK to pass all the values down.

applying the green flag

In this example, when isReady sends an event, all the values will be passed to sink(). So, after all, you can think isReady as a signal.

Conclusion

  • You need to pass a publisher to use drop(untilOutputFrom:)
  • The publisher passed as an argument to drop(untilOutputFrom:) is a flag which indicates when it’s ok to pass the values.

--

--

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!