0
繞圈試圖弄清楚這一點......ng2-redux @select返回AnonymousSubject
新的還原。剛剛進入Angular2 ...
我試圖從accountReducer選擇一個用戶帳戶對象
const INITIAL_STATE: IAccount = {
anonymous: true,
email:""
};
export function accountReducer(state: IAccount = INITIAL_STATE, action:any):IAccount
{
switch (action.type) {
default:
return state;
}
}
這是rootReducer:
export interface IAppState {
account?: IAccount;
}
/**
* root reducer
*/
export default combineReducers<IAppState> ({
account: accountReducer
});
然後,當我選擇註冊頁面上該帳戶我得到一個AnonymousSubject對象。
export class AccountSignupFormComponent {
//@select(state => state.account) account;
@select() account;
constructor(
private _redux: NgRedux<IAppState>,
private _actions: AccountActions
){}
ngOnInit(){
console.log(this.account);
// account is an AnonymousSubject from RxJs.
}
如果我看一下this._redux.getState(),那麼狀態會在那裏看起來正確。
我猜我錯過了一些簡單的東西,但我沒有看到它。
任何人都能看到我失蹤的東西嗎?