Adding service dependent logic to NGRX actions in an Angular application

I have an actions file like this:

export enum ActionTypes {
  FailureAction = 'Failure action',

export class FailureAction implements Action {
  readonly type = ActionTypes.FailureAction;

  constructor(public payload: any) { }

export type ActionTypes = FailureAction;

I want to add some logic in the FailureAction class so that whenever this action gets called, we call a service that decides how to show an error (the only parameter is a code). I created a class that has the code parameter in the constructor and uses a dependency injector defined in the app module (Inject a service manually) to get the service needed. Then I extended the FailureAction with the newly made class and called super() with the code parameter in the constructor. When I dispatch the FailureAction the console gets bombarded with errors and crashes the whole application.


Is this even doable the way I’m trying to do it? Any alternative suggestions?

Source: Angular Questions