I am trying to do parallel requests with forkJoin
but sometimes for no reason one of the request is cancelled or one of requests returns 200 but data Failed to load response data . If I make sepratae requests they work as expected.
private _getGeneralEventInfo() {
const id = this.route.snapshot.paramMap.get('id');
if (id) {
// Working if make separate requests
// this._getEventInfo(id).subscribe();
// this.typeOfService.getTypeOfServices().subscribe();
// this.workOrder.getEquipments().subscribe();
forkJoin([
this._getEventInfo(id),
this.typeOfService.getTypeOfServices(),
this.workOrder.getEquipments(),
])
.pipe(
isLoading(v => this.$isLoading.set(v)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe();
}
}
export const isLoading = <T>(stateChanged: (state: boolean) => void) =>
function wrapOperatorFunction(source: Observable<T>): Observable<T> {
stateChanged(true);
return source.pipe(finalize(() => stateChanged(false)));
};
sometimes 200 but with failed data
sometimes cancelled