檢查一下都有哪幾處使用到了這個字符串常量:
(1) 定義 State 數據結構:
(2) 用於創建 feature selector,傳入 ROUTING_FEATURE 作為輸入參數:feature name
(3) 在 routing.module.ts 裏,作為 StoreModule.forFeature 和 StoreRouterConnectingModule 的輸入參數。
對於場景3,我們看看 StoreModule.forFeature 調用返回的類型為ModuleWithProviders 的數據明細。
每個 module 在導入時,會執行其 ts 代碼裏的可執行代碼:
storeModule.forFeature 返回的數據:
這些 providers 我可以在其他 module 裏使用嗎?
forFeature 的第二個參數必須是 reducer,類型為 ActionReducerMap 或者 ActionReducerMap 的 injection type:
Spartacus 選擇的是後者:
更多Jerry的原創文章,盡在:"汪子熙":