Ngxs state with emitter problem with sonar test - state was used before it was defined?

30 Views Asked by At

I use NGXS and Emitters. Everything works fine but when I use @Emitter in the state itself. Sonar tests will fail with error "'GeneralDataState' was used before it was defined." on the line with @Emitter(GeneralDataState.getApproversFromApi). This emitter works fine but compared to emitters in components, there is this error. Any advices? Thanks

export class GeneralDataState {
  private static userDataService: UserDataService;

  @Emitter(GeneralDataState.getApproversFromApi)
  public static _getApproversFromApi: Emittable<string>;

  constructor(injector: Injector) {
    GeneralDataState.userDataService = injector.get<UserDataService>(UserDataService);
  }
  .
  .
  .
  @Receiver({ cancelUncompleted: false })
    public static getApproversFromApi(ctx: StateContext<GeneralDataStateModel>, { payload 
  }: EmitterAction<string>) {
  ...
  }
}
0

There are 0 best solutions below