opsb
(Oliver Searle-Barnes)
1
Given the following
var separateTimers = [1.0,2.0,3.0].map{ n in
Timer.publish(every: n, on: RunLoop.main, in: .default)
.autoconnect()
.map{ x in n }
}
var mergedTimers = SomePublisher(separateTimers)
mergedTimers.sink{ value in print(value) }
What should be on the SomePublisher... line to merge the separateTimers into a single stream?
I've looked at the following:
merge - only combines two publisher not a list
append - doesn't have the contentsOf option that Array.append has
but I'm looking to interleave the values from multiple publishers. Which Publisher/operator am I looking for?
I think you want Publishers.MergeMany.
let mergedTimers = Publishers.MergeMany(separateTimers)
opsb
(Oliver Searle-Barnes)
3
That does the job nicely, thanks!