When I add in .map(...)
notification service and CLOSE dialog function I get errors.
What is the proper way to set this? Here is my effect
@Effect()
addNewUser$ = this.actions$.pipe(
ofType(actions.UserActionTypes.addNewUser),
mergeMap((user: actions.addNewUser) =>
this.userService.createUser(user.user).pipe(
map(() => {
new actions.LoadUsers(),
this.notificationService.success("User added successfully!"); <--- added
this.dialogRef.closeAll(); <--- added
}),
catchError(error => of(new actions.Error(error.error)))
)
)
);
I get error
core.js:6014 ERROR Error: Effect "UserEffects.addNewUser$" dispatched an invalid action: undefined
TypeError: Actions must be objects
Any help? Thnx
Like the error says, you should be returning an action.
The map
doesn't have a return value, so it will return undefined
- causing the error.
Try the following:
this.notificationService.success("User added successfully!"); <--- added
this.dialogRef.closeAll(); <--- added
return new actions.LoadUsers();