1
votes

I have a function that writes/modifies the data and returns an Observable to track the progress of the task.

func modifyChunk(data: SomeData) -> Observable<Double>

Now in my use case user may preform N number of operations in runtime randomly, where he may modify same data over and over. I'm looking for a way to hold/postpone new Observable from modifyChunk(data:) till previously existing observable is finished, and once that happen immediately kick start this new Observable and so on.

I figured out that, I may need a queue that will take Observable tasks at runtime and execute them in FIFO manner. But I'm not able figure out how to achieve that using RxSwift.

1
This sounds like a job for a serial dispatch queue. Or a Swift 5.5 Actor :)Cristik

1 Answers

0
votes

This sounds like a job for concat which will subscribe to an observable and wait until it's complete before subscribing to the next one. You haven't provided enough information, but if the number of observables is static, then you can use the Observable.concat operator. If the number of observables is dynamic, then concatMap is the solution you need.