【发布时间】:2017-10-28 16:58:13
【问题描述】:
我尝试将 redux 应用到我的应用,但无法订阅更改。
组件:
从'../../core/reducers/authorization'导入{ USER_SIGN_IN};
this.store.dispatch({ type: USER_SIGN_IN, payload: data: data[0]});
减速器:
import { ActionReducer, Action } from '@ngrx/store';
export const USER_SIGN_IN = 'USER_SIGN_IN';
export function userSingIn(payload: T) {
return {
type: 'USER_SIGN_IN',
payload: payload
}
}
服务:
this.store.select(state => state.user).subscribe((user)=> {
console.log('user:', user);
});
应用模块
StoreModule.provideStore({ user : userSingIn }),
My payload object is empty, i don't understand why
There is console log of subscription:
Object {type: "USER_SIGN_IN", payload: Object}payload: Objectpayload: Objectpayload: undefinedtype: "USER_SIGN_IN"__proto__: Objecttype: "USER_SIGN_IN"__proto__: Objecttype: "USER_SIGN_IN"__proto__: Object
【问题讨论】:
-
你没有
dispatch任何东西到你的商店。所以它只会是空的 -
@Tanya 如果你想了解更多关于 redux 架构的细节,你可以在 adv 标签下查看这个链接rahulrsingh09.github.io/AngularConcepts - ngrx
标签: angular redux observable reduce subscription