Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular NGRX为什么减速器对从效应中发出的动作不作出反应?_Angular_Typescript_Rxjs_Ngrx - Fatal编程技术网

Angular NGRX为什么减速器对从效应中发出的动作不作出反应?

Angular NGRX为什么减速器对从效应中发出的动作不作出反应?,angular,typescript,rxjs,ngrx,Angular,Typescript,Rxjs,Ngrx,NGRX实现的一个功能包括 两个动作 export class UpdateWordListAction implements Action { static readonly TYPE = 'UPDATE_WORD_LIST'; readonly type = "UPDATE_WORD_LIST"; constructor() {}; } export class WordListLoadedSuccessAction implements Acti

NGRX实现的一个功能包括

两个动作

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[]) {};
}
客户端

this.store.dispatch(new UpdateWordListAction());
@Effect()
testEffect$ = this.actions$.pipe(
   ofType(UpdateWordListAction.TYPE), 
   tap(console.log), // Runtime: UpdateWordListAction {type: "UPDATE_WORD_LIST"}
   switchMap(() => this.wordService.getWordList()), 
   tap(console.log),  // Runtime: (2) [{…}, {…}]
   map(words => new WordListLoadedSuccessAction(words)),
   catchError(() => EMPTY));
效果

this.store.dispatch(new UpdateWordListAction());
@Effect()
testEffect$ = this.actions$.pipe(
   ofType(UpdateWordListAction.TYPE), 
   tap(console.log), // Runtime: UpdateWordListAction {type: "UPDATE_WORD_LIST"}
   switchMap(() => this.wordService.getWordList()), 
   tap(console.log),  // Runtime: (2) [{…}, {…}]
   map(words => new WordListLoadedSuccessAction(words)),
   catchError(() => EMPTY));
和减速器

export const reducers = combineReducers<AppState, any>({
    words(state = initialAppState.words, action: WordListLoadedSuccessAction) {
        console.log(action); // Never reached!
        return action.words;
    }
  });
导出常量减速机=组合减速机({
words(state=initialAppState.words,action:wordListedSuccessAction){
console.log(操作);//从未到达!
返回动作。单词;
}
});

我不明白这个减速机为什么不工作。请帮助找出问题所在。

您不使用现代NgRx方法(如
createAction
createReducer
)的任何原因?后者允许您在上使用,以方便操作减速器的设置。您的减速器是否已在相应的模块中注册?