我目前在应用程序中成功地使用了 @ngrx/store(还有 @ngrx/effects 和 @ngrx/store-devtools)。现在我想制作一个模块,这个模块最好独立于应用程序的其他部分。问题是如何在其中也使用 @ngrx/store?我是否可以将新的 reducer 添加到现有的“app”store 中? 我希望避免将模型从模块移动到应用程序并将 reducer 注册到应用程序中。有没有人有解决方案?以下是示例代码:
// App declarations
export const APP_IMPORTS = [
.
.
.
StoreModule.provideStore(reducer),
EffectsModule.run(someEffects),
STORE_DEV_TOOLS_IMPORTS
];
@NgModule({
declarations: [
APP_DECLARATIONS,
AppComponent
],
imports: [
APP_IMPORTS
],
providers: [APP_PROVIDERS],
bootstrap: [AppComponent]
})
export class AppModule {
}
在新模块中:
// Module declaration
@NgModule({
imports: [CommonModule,
FormsModule,
StoreModule.provideStore({ counter: counterReducer }) // <-- how to change this to just add to current store new reducer??
],
exports: [MyTestComponent],
declarations: [MyTestComponent],
})
export class SomeModule {
}
还有谁知道如何更改@ngrx/store在devtool中显示的名称?将其从ngrx-store-some_random_number更改为某个app_name?
非常感谢