I have a view model with a few different functions that look like:
func somethingSignal() -> SignalProducer<Void, NSError>
{
return SignalProducer {
sink, disposable in
sink.sendNext(blabla)
sink.sendCompleted()
}
}
Now, these signals need to be run in sequence - one cannot start before the preivous has been Completed. I therefore have another function called something like:
func setup() -> SignalProducer<Void, NSError>
{
return somethingSignal()
.then(somethingSignal2())
.then(somethingSignal3())
}
I was under the impression that then is the function to use for this sort of behaviour. Signal3 shouldn't begin until Signal2 has completed, which shouldn't start until Signal1 has completed.
The function that calls setup has the start() call.
Where am I going wrong with this?
That looks correct!
Alternatively, you can concatenate all the signals:
Since your type is
Voidyou probably don't care about the values emitted. If you do, however, note that this has slightly different semantics: it will emit values from all the signals, unlikethen.