I have an Epic. I want to pass 2 HTTP Get Requests. They are both Promised based. But it only bring data for the first processed one. THE Epic:
const processorsListEpic = (action$, store, deps) =>
action$.ofType(Type.LIST_ATTEMPT).pipe(
switchMap(() =>
observableFromHttpPromise(
deps.getList(store), // This bring data
deps.getTargets(store) // This doesn't
).pipe(
mergeMap((listResult, targetResult) => {
console.log('Target:', targetResult.data);
console.log('List', listResult.data);
return of(
R.mergeAll(
Actions.ListSuccess(listResult && listResult.data),
Actions.TargetsSuccess(targetResult && targetResult.data)
)
);
}),
catchError(error => of(Actions.ListFailure(error)))
)
)
);
The function observableFromHttpPromise
is the following:
// From is from rxjs
export const observableFromHttpPromise = promise => from(promise);
Any Ideas? If I change the order of the requests, the other data are there..
Try this
observableFromHttpPromise(Promise.all(
deps.getList(store),
deps.getTargets(store),
))