I have developed two different approaches to achieve the same effect, and surprisingly both are functioning correctly. However, I am struggling to comprehend the nuances between them and determine which one is more "correct".
See them outlined below:
Option 1. The IDE is unable to infer the type for instance
in the final map
.
pollingStarted$ = createEffect(() =>
this.actions$.pipe(
ofType(pollingStarted),
mergeMap(action => action.instances),
map(instance => performRequest({ instance }))
)
);
Option 2. All types are properly defined and clear. I personally consider this to be the more accurate approach, but I am eager to uncover and comprehend the distinctions.
pollingStarted$ = createEffect(() =>
this.actions$.pipe(
ofType(pollingStarted),
mergeMap(({ instances }) =>
instances.map(instance => performRequest({ instance }))
)
)
);