Skip to content

Instantly share code, notes, and snippets.

@ramunasjurgilas
Created February 27, 2020 07:40
Show Gist options
  • Save ramunasjurgilas/5b555f4356fe11617b2a3fe74af703b7 to your computer and use it in GitHub Desktop.
Save ramunasjurgilas/5b555f4356fe11617b2a3fe74af703b7 to your computer and use it in GitHub Desktop.
dropUntilOutputFrom() as filtering operator
let on = PassthroughSubject<Void, Never>()
let strings = PassthroughSubject<String, Never>()
strings
.drop(untilOutputFrom: on)
.sink(receiveValue: { print($0) })
["a0", "a1", "b2", "a3", "c4", "a5", "d6"]
.forEach {
strings.send($0)
if $0.hasPrefix("b") {
on.send()
}
}
// Output:
// a3
// c4
// a5
// d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment