I have the following code
@Effect()
executeMission$ = this.actions$.pipe(
ofType<featureActions.ExecuteUsedDroneMissionRequest>(featureActions.ActionTypes.ExecuteUsedDroneMissionRequest),
withLatestFrom(this.store$.pipe(select(MissionsStoreSelectors.selectAllEntities))),
switchMap(([action, missions]) => {
const mission = missions[action.payload.missionId]
//....
})
);
Now, I have a selector which is supposed to remove this line => const mission = missions[action.payload.missionId]
export const selectAllEntities: (state: object) => Dictionary<IMission> = featureAdapter.getSelectors(selectMissionState).selectEntities;
export const getById = () => createSelector(
selectAllEntities,
(entities, props) => entities[props.routeId]
);
but to use it, I need to add the action payload into the withLatestFrom like this
withLatestFrom(this.store$.pipe(select(MissionsStoreSelectors.selectById(), { missionId: action.payload.missionId }))),
but action is not available outside the switchMap.
Is it possible to do this ?
Use a concatMap
, this example comes from my post Start using ngrx/effects for this
concatMap(action =>
of(action).pipe(
withLatestFrom(store.pipe(select(getUserName)))
)
),