如何在ngrx / router-store上添加另一状态?

时间:2018-10-03 14:36:01

标签: angular ngrx ngrx-store ngrx-store-4.0 ngrx-router-store

我有一个如下定义的根级路由器存储。

export interface RouterStateUrl {
  url: string;
  queryParams: Params;
  params: Params;
}

export interface State {
  routerReducer: RouterReducerState<RouterStateUrl>;
  // init: fromInit.InitState;
}

export const reducers: ActionReducerMap<State> = {
  routerReducer: routerReducer,
  // initReducer: fromInit.reducer
};

export const getRouterState = createFeatureSelector<
  RouterReducerState<RouterStateUrl> 
>("routerReducer");

我正在尝试添加一个称为init的附加状态,我想与路由器状态一起进行跟踪。如何创建也可以访问init状态的功能选择器?换句话说,如何创建未与RouterReducerState类型绑定的功能选择器?

1 个答案:

答案 0 :(得分:0)

就像您对路由器所做的一样:

export interface State {
  routerReducer: RouterReducerState<RouterStateUrl>;
  initReducer: fromInit.State;
}

export const reducers: ActionReducerMap<State> = {
  routerReducer: routerReducer,
  initReducer: fromInit.reducer
};

export const getRouterState = createFeatureSelector<
  RouterReducerState<RouterStateUrl> 
>("routerReducer");

export const getInitState = createFeatureSelector<
  fromInit.State 
>("initReducer");