How do I create an observable of an array from an array of observables?

后端 未结 2 1810
野趣味
野趣味 2020-12-24 06:05

I have an array of Thing objects that I want to convert to ConvertedThing objects, using an asynchronous function that returns Observable<

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 06:37

    For future readers:

    Using .merge() and .toArray() will emit a single element when all observable sequences complete. If any of the observables keeps emitting, it will not emit or complete.

    Using .combineLatest() will return an Observable that emits the full list every time any observable changes:

    let arrayOfObservables: [Observable] = ...
    let wholeSequence: Observable<[E]> = Observable.combineLatest(arrayOfObservables) { $0 }
    

提交回复
热议问题