I don't understand how to avoid such error NGRX TypeError: Actions must have a type property
. Please help to find out what is wrong.
I have two actions,
export class UpdateWordListAction implements Action {
static readonly TYPE: 'UPDATE_WORD_LIST';
readonly type: "UPDATE_WORD_LIST";
constructor() {};
}
export class WordListLoadedSuccessAction implements Action {
readonly words: Word[];
static readonly TYPE: 'WORD_LIST_LOADED_SUCCESS';
readonly type: "WORD_LIST_LOADED_SUCCESS";
constructor(words: Word[]) {};
}
One effect,
@Injectable()
export class MyEffects {
testEffect$ = createEffect(() =>
this.actions$.pipe(
ofType(UpdateWordListAction.TYPE),
switchMap(() => this.wordService.getWordList()),
map(words => new WordListLoadedSuccessAction(words)),
catchError(() => EMPTY)));
constructor(
private actions$: Actions,
private wordService: WordService
) {}
}
And such client
this.store.dispatch(new UpdateWordListAction());