0
我尝试将redux应用于我的应用,但无法订阅更改。 组件:
从'../../core/reducers/authorization'导入{USER_SIGN_IN}; this.store.dispatch({type:USER_SIGN_IN,payload:data:data [0]});Redux Angular2订阅
减速机:
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'什么你的店。所以,如果你想获得终极版架构一些细节,你可以进阶选项卡下检查此链接 https://rahulrsingh09.github.io/AngularConcepts/ 它将是空的只有 – Aravind
@Tanya - NGRX –