简体   繁体   中英

How to chain dynamic signals in ReactiveCocoa

I have a situation where I have to make one signal for every network request, and the amount of network request is dynamic (dependent on the amount of images the user selected). Also this requests signals have an order, one has to be executed after the other.

So in this situation I have to chain a dynamic number of dependent signals. I need a competition block for every signal, and a competition block for the whole sequence, once all the chained signals have completed.

I know -then: and -flattenMap are useful commands for sequencing signals, but is there a way to chain an unknown number of signals?

Just founded the solution, with -concat: you are able to concatenate signals, and execute blocks for each signal, competition, and error.

[[RACSignal concat:sequencedSignals] subscribeNext:^(ImagePosted * imagePosted) {
    // Block for each signal 
} error:^(NSError *error) {
    // Error block
} completed:^{
    // Sequence completition block
} ]; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM