Skip to content

Instantly share code, notes, and snippets.

@NachoSoto
Created February 22, 2016 04:17
Show Gist options
  • Save NachoSoto/fd1949b6dc537353bf67 to your computer and use it in GitHub Desktop.
Save NachoSoto/fd1949b6dc537353bf67 to your computer and use it in GitHub Desktop.
Converting [SignalProducer<U>] -> SignalProducer<[U]>
// https://twitter.com/davedelong/status/701621040015810560: @NachoSoto is there a way to take a # of SignalProducer<U,E> and turn them in to SignalProducer<[U], E>? Like combineLatest but w/o tuples
let signals: [SignalProducer<T, E>]
let result: SignalProducer<[T], E> =
SignalProducer(values: signals) // create a producer that emits all signals.
.flatten(.Merge) // merge all values that they emit.
.collect() // collect all values into an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment