试图理解ngrx示例应用程序,被卡住,无法找出其用例。
在以下摘自ngrx-example-app
的代码中,州的重要性是什么export interface State extends fromRoot.State {
[booksFeatureKey]: BooksState;
}
/** Provide reducer in AoT-compilation happy way */
export function reducers(state: BooksState | undefined, action: Action) {
return combineReducers({
[fromSearch.searchFeatureKey]: fromSearch.reducer,
[fromBooks.booksFeatureKey]: fromBooks.reducer,
[fromCollection.collectionFeatureKey]: fromCollection.reducer,
})(state, action);
}
答案 0 :(得分:0)
这样做没有运行时差异,只是使打字稿意识到您“拥有”了根状态。
如果您从功能状态选择器中访问根状态或根选择器,则使打字稿满意是必需的。