I am learning about effects and and trying to dispatch a warning notification when a search fails. My search actions are defined as such
export enum SearchActionTypes {
SearchActionSearch = '[Search] Action search',
SearchActionFulfilled = '[Search] Action search fulfilled',
SearchActionFailed = '[Search] Action search failed',
}
I have a service in my app that can display notifications and I am trying to call this service when a SearchActionFailed Action is dispatched. However, I don't know how to build the effect for this. Currently I am here:
@Injectable()
export class NotificationEffects {
@Effect()
// show error notification when an illegal value is entered into search
searchFailEffect = this.actions$.pipe(
ofType(Search.SearchActionTypes.SearchActionFailed),
);
constructor(private actions$: Actions,
private notificationService: NotificationService) {}
}
I want to call the notification service API when the effect catches the action and the call is structured like this:
this.notificationService.createNotification('type', 'message'))
I don't need anything from the action payload just a call to this service when the fail action is dispatched. However, I do not know how to structure that effect. My main issue is an effect has to return an observable but I don't need anything I just need to know when a search action fails so I can call the service to display a notification warning the user that their input is false