Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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 如何使用StoreModule.forFeature和ngrx 8.0.0 beta注册单个减速器_Angular_Ngrx_Ngrx Store_Ngrx Store 4.0 - Fatal编程技术网

Angular 如何使用StoreModule.forFeature和ngrx 8.0.0 beta注册单个减速器

Angular 如何使用StoreModule.forFeature和ngrx 8.0.0 beta注册单个减速器,angular,ngrx,ngrx-store,ngrx-store-4.0,Angular,Ngrx,Ngrx Store,Ngrx Store 4.0,在我的功能模块中,我使用createReducer方法创建我的reducer,如下所示: export const reducer = createReducer( new InitState(), on(loadData, state => { return { ...state, isLoading: true }; }) ); 但当我在模块类中注册上述reducer时,如下所示: StoreModule.forFeature('my-module', reducer), 我在编译

在我的功能模块中,我使用createReducer方法创建我的reducer,如下所示:

export const reducer = createReducer(
new InitState(),
on(loadData, state => {
return {
...state,
isLoading: true
};
})
);
但当我在模块类中注册上述reducer时,如下所示:

StoreModule.forFeature('my-module', reducer),
我在编译项目时遇到以下错误:

错误myModule.module.ts(38,47):在“MyModuleModule”的模板编译过程中出错 decorators中不支持函数调用,但在“reducer”中调用了“createReducer” “reducer”在myreducer.reducer.ts(14,24)调用“createReducer”。

有人知道会出什么问题吗?或者我该如何注册单个减速机,因为我所看到的所有示例都是将组合减速机与多个减速机结合使用,我想知道,对于一个减速机,我们该如何注册


多谢各位

您需要包装减速器,使其与AOT编译兼容:

export function myAOTSafeReducer(
    state: State | undefined,
    action: Action
) {
    return reducer(state, action);
}

然后在状态中引用这个导出的命名函数。

我在这里是因为周六的流:p我告诉过你离开旧的升级路径,依靠ng更新示意图,但是没有,你直接进入了包,得到了你的噩梦,哦,好吧:PBTW,我花了周日的时间制作了一个演示,并写了一篇关于我提到的反应式数据源的文章:想要得到你的反馈:)