How to set reducer for @ngrx/store in angular 6 that set {[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;
}
}
in Component this.store.dispatch(new appActions.Register(this.name, this)); I want to set state _register[this.name] anyone can help? thanks