If you look at this question. the problem was really simple, but solutions were more complicated, to address more details I am asking this question.
If you look at
I think you can use RxJs combineLast to achieve what you want.
If you combine the result of the first call and the next call with combineLast will be able to subscribe and get both objects and return a combination of both of them.
Here's an example:
const objA = {xpto: 'xis'};
const objB = {moreData: 'pato'};
of(objA).pipe(
map((a) => {
return combineLatest(of(a), of(objB));
})
).subscribe((result) => {
result.pipe(
map(([a, b]) => {
return {
newXpto: a.xpto,
newMoreData: b.moreData
};
})
).subscribe((combinedObjects) => {
console.log(combinedObjects);
})
})
Something like this should work. I don't know if it is the more straigthfoward answer but I did it quickly. Nevertheless it gives you a sense of how you could do it.