Как установить редуктор для @ ngrx / store в angular 6, который устанавливает {[key: string]: AnyComponent}
app.action.ts
export enum BarActionTypes {
Register= '[bar] Register'
}
export class Register implements Action {
readonly type = BarActionTypes.Register;
constructor(public key: string, public anyComponent: BarComponent) {}
}
export type appActions = Register;
app.reduser.ts
export interface BarState {
_registry: {[key: string]: BarComponent};
}
const InitBarState: BarState = {
_registry: {}
};
export function Reducer(state= InitBarState, action: appActions): BarState {
switch (action.type) {
case BarActionTypes.Register:
return {
...state,
_registry: _registry[action.key]=action.anyComponent
};
default:
return state;
}
}
в Компоненте this.store.dispatch (новый appActions.Register (this.name, this));Я хочу установить состояние _register [this.name], кто-нибудь может помочь?спасибо