我有一个带有分派 FETCH 操作的组件的模块,该组件从 API 获取数据,然后分派一个 RECEIVED 操作。它运行良好。
然后我将模型、动作和状态复制到另一个模块和组件(具有不同的获取和接收)并且它不起作用。记录器将操作显示为已调度,但未执行代码。
文件.action.ts
export class FetchFolders {
static readonly type = '[Documents] Fetch folders';
constructor(public payload: string) { }
}
文件.state.ts
@Action(FetchFolders)
FetchFolders(state: StateContext<DocumentStateModel>, { payload }: FetchFolders) {
console.log('inside');
return this.http.get(`assets/fake-data/${payload}/documents.json`)
.pipe(
tap(result => this.store.dispatch(new ReceiveFolders(<DocumentFolder[]>result)))
);
}
我已将代码减少到最低限度,以检查一切是否正常。还检查了导入(有时我从错误的库中导入)但仍然没有运气。
知道发生了什么吗?