Skip to content

Instantly share code, notes, and snippets.

@ramunasjurgilas
Created February 27, 2020 07:58
Show Gist options
  • Save ramunasjurgilas/280e3a8105e2700f6b6a98abbfb2fbaf to your computer and use it in GitHub Desktop.
Save ramunasjurgilas/280e3a8105e2700f6b6a98abbfb2fbaf to your computer and use it in GitHub Desktop.
prefix() as filtering operator
let strings = PassthroughSubject<String, Never>()
strings
.prefix(3)
.sink(receiveValue: { print($0) })
["a", "b", "c", "d", "e"]
.forEach {
strings.send($0)
}
// Output:
// a
// b
// c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment