Skip to content

Instantly share code, notes, and snippets.

@serhiybutz
Last active August 11, 2020 04:14
Show Gist options
  • Save serhiybutz/667acb426d2fbfd1cd58656e3134f474 to your computer and use it in GitHub Desktop.
Save serhiybutz/667acb426d2fbfd1cd58656e3134f474 to your computer and use it in GitHub Desktop.
Combine: zip issue, 05
import Combine
let events = PassthroughSubject<String, Never>()
let numbers = (0...).publisher
.print("numbers")
let subscriber = events
.print("events")
.zip(numbers)
.map { ($1, $0) } // swap
.customSink(
initialDemand: .max(5),
receiveValue: { value in
print(value)
})
events.send("foo")
events.send("bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment