I need to fetch IDs from my state as separate Observable
s, combine all of them into one Observable
and subscribe()
to it.
I need that my subscriber will eventually get an array of resolved Observable
results.
Also I need to keep this subscription open, so if one of my inner Observable
s changes my subscriber will be notified.
This is my code:
getTransactionsByIDs(transactionsIDs){
return Observable.of(transactionIDs
.map(transactionID => this.getTransactionByID(transactionID)));
}
this.transactionsService.getTransactionsByIDs(transactionsIDs)
.subscribe(transactions=>{
....
})
The result of the above code in the subscriber function is an array of unresolved stores.
How can I resolve each store and combine all of them together?
I've also tried to use Observable.from()
on the transactionsID
s to transform each ID into an Observable
and then resolve it. It works fine, but then my subscriber getting notified on every ID separately. If there's a way to batch all of the Observable.from()
results (while keeping subscription open), please let me know.
This is how my Observable.from()
looks like:
getTransactionsByIDs(transactionsIDs){
return transactionIDs
.mergeMap(transactionID => this.getTransactionByID(transactionID));
}
this.transactionsService.getTransactionsByIDs(Observable.from(transactionsIDs))
.subscribe(transactions=>{
....
})