I'm new in NGXS and I try to figure out the right way to send UI toast notifications after success/error HTTP response using NGXS? Should we handle it in state:
@Action(SomeRequestSuccess)
public success(ctx: StateContext<SomeModel>, action: SomeRequestSuccess) {
// like this
this.store.dispatch([new SuccessToastNotification(msg)])
// or just use service
this.toastsService.showToast(action.payload.message, ToastsTypes.SUCCESS);
}
or somehow keep error/success response in state and then use it in component:
@Select(selectors.someRequestSuccess) public success$: Observable<any>;
ngOnInit() {
this.success$.subscribe(s =>
this.toastsService.showToast(s.message, ToastsTypes.SUCCESS);
this.reloadReport();
);
}
// and same way for error
...
or any other way that you could suggest. Thanks in advance!