2

I have an array of signal producers that fetch similar objects from the backend like [SignalProducer<Object, NSError>]. How can I zip them to have array of their results [Object] every time they all are finished? I know there zip operators with predefined number of producers, but it is not a case, as the number of requests to send is known only in runtime.

benchman
  • 115
  • 4

1 Answers1

3

SignalProducer has a static zip function that accepts a sequence of producers.

jjoelson
  • 5,771
  • 5
  • 31
  • 51
  • Yes, I've tried it. But it gives a compile error, that this function still wants second argument.
    var producers: [SignalProducer] = []
    ...
    return SignalProducer.zip(producers)
    – benchman May 22 '17 at 12:35
  • Hmm, maybe it's a type inference ambiguity. Try `SignalProducer.zip(producers)` – jjoelson May 22 '17 at 12:44
  • 1
    No, it was my fault. Had the wrong result type from the function. Thank you! – benchman May 22 '17 at 13:30