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 –