I have two observables of arrays (settings, mappings). I need to generate from these an object[] array, where each object is of the form { setting, mapping } in order.
I've attempted to forkJoin the two observables, but I'm not sure how to proceed. The method is in a service and should return Observable<object[]>.
I was thinking I need to somehow zip and map the result of forkJoin to the objects, but I can't seem to get this done.
RXJS docs are not particularly helpful, or perhaps I don't know how to read them correctly. Any suggestions are appreciated in advance.
Update
I was able to get it to work with the following implementation:
return forkJoin([settings, mappings]).pipe(
map(([settings, mappings]) => {
const cards = settings.map((setting, index) => {
const card: Card = {
settings: setting,
apps: mappings[index].appInformation,
};
return card;
});
return cards;
})
);
I am too new to web programming to analyze the efficiency of my implementation. If there is a better way... please...