我有一个带有应用主题配置的NgRx商店。当我在async
navbar.component.html
管道时
<div class="navbar" [style.background]="(theme | async).uiElements['navbar_background'].getColor()">
并从我的change-colors.component.ts
更改导航栏背景颜色,一切正常。但是当我在navbar.component.ts
ngOnInit() {
this.theme = this.themeStore.select('theme');
this.themeSub = this.theme.subscribe(
() => console.log('subs works')
);
}
&#39; subs works&#39;文本没有出现在控制台中,i。即订阅不起作用。为什么会这样呢?
主题缩减器:
export function themeReducer(state = initialState, action: ThemeActions.ThemeActions) {
switch (action.type) {
case (ThemeActions.CHANGE_COLOR):
state.uiElements[action.payload.target] = new UiElement(
state.uiElements[action.payload.target].name,
action.payload.target,
{ R: action.payload.value.R, G: action.payload.value.G, B: action.payload.value.B }
);
return state;
default:
return state;
}
}