Reputation: 261
So since the V10 upgrade to NGRX you can no longer pass in a type of Action to the effect, as Actions are now declared as functions isntead of classes. Is there still a way to handle this in V10?
export const myAction = createAction(
'[myAction]',
props<{person: User}> ()
);
@Effect({ dispatch: false })
x = this.actions$.pipe(
ofType**<myAction>**('[myAction]'),
I don't have access to person prop. Where in before version 10 you did because it was a class...
Upvotes: 0
Views: 237
Reputation: 3393
See https://ngrx.io/guide/effects#incorporating-state
myAction
directly to ofType
action.person
@Effect({ dispatch: false })
x = this.actions$.pipe(
ofType(myAction),
map(action => of(action.person))
);
Also it would be preferable to use the new createEffect
syntax.
Stackblitz: https://stackblitz.com/edit/so-ngrx-oftype?file=index.ts
Upvotes: 1