我在當前應用程序中成功使用了@ ngrx/store(也是@ ngrx/effects和@ ngrx/store-devtools)。現在我想創建模塊,這將是獨立於其他應用程序的理想選擇。問題是如何在其中使用@ ngrx/store? 我能以某種方式將新的減速器添加到現有的「應用程序」商店嗎?我想避免將模型從模塊移動到應用程序,並將減速器註冊到應用程序中。有沒有人有這個解決方案?示例代碼如下:
將@ ngrx/store存儲到角度2模塊中
// 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 {
}
也是劑量人知道如何chnage的名字@ NGRX /存儲上devtool顯示?把它改成ngrx-store-some_random_number到一些app_name?
非常感謝
有rpthat涉及到當前打開的問題這個:https://github.com/ngrx/store/issues/281和https://github.com/ngrx/store/issues/211還有一個提議,但還沒有實施的變化:https:// gist .github.com/MikeRyan52/5d361681ed0c81e38775dd2db15ae202 – cartant
這個我們將是一件很棒的事。我們可以更改當前商店的名稱嗎? – CoYoTe