在一个效果类中,我得到了以下代码
withLatestFrom(this.store.pipe(select(selectSettings))),
tap(([action, settings]) => {
console.log('settings', settings);
/*
print {lang:'en',theme:'dark', type: "[Settings Page] Change Language"}
instead of simply {lang:'en',theme:'dark'}
*/
this.localStorageService.setItem(SETTINGS_KEY, settings);
}
我想知道,请,如何摆脱它以及为什么有这个额外的属性,感谢
检查[Settings Page] Change Language
减速器。它看起来不正确,并将自己的类型添加到状态
可能会发生这种情况
const changeLanguage = createActions('[Settings Page] Change Language', props<{ lang: string }>())
on(changeLanguage, (state, action) => {
...state,
...action // Action object is { lang: 'eng', type: '[Settings Page] Change Language' }
});
// correct version
on(changeLanguage, (state, { lang }) => {
...state,
lang
// lang: action.lang - if you don't spread the action object
});