I have 2 Actions and an Effect for these 2 actions using ofType
operator as below:
export const myActions = {
actionA: createAction(`actionA`, props<{ a: string }>()),
actionB: createAction(`actionB`, props<{ b: number }>())
}
myEffect$ = createEffect(() =>
this.actions$.pipe(
ofType(myActions.actionA, myActions.actionB),
mergeMap(action => {
// How to convert action object to correct type and access action.a or action.b props?
if (action.type == myActions.actionA) {
console.log(action.a); // compile error
} else if (action.type == myActions.actionB) {
console.log(action.b); // compile error
}
})
), {dispatch: false}
);
How can I check and access props of actions (action.a and action.b) and with auto-completion from IDE?