I am trying to have a Ngxs action that takes a parameter along with Payload. I use this parameter to decide if I need to send a notification or not.
@Action(UpdateUser)
async UpdateUser(
ctx: StateContext<ProfileStateModel>,
userProfile: User,
notify: boolean
): Promise<void> {
await this.updateProfileSvc(userProfile){
.subscribe({
next: (data: User) => {
ctx.setState({...state, sendNotification: notify});
}
})
}
}
User is the payload in this Action. When I pass the second parameter “notify” with value “true/false”, I always receive it as undefined.
How to have a parameter other than payload in the Ngxs action?
I tried to print the value of notify in the console, and I see it “undefined” always.
Please share your inputs here/ Thanks.