ngrxストアに対処する予定のアクションにディスパッチしない問題が発生しています。コンポーネントからアクションがディスパッチされたときにngrxエフェクトが呼び出されない
signin() {
this.formStatus.submitted = true;
if (this.formStatus.form.valid) {
this.store.dispatch(new StandardSigninAction(this.formStatus.form.value.credentials));
}
}
アクション:
export const ActionTypes = {
STANDARD_SIGNIN: type('[Session] Standard Signin'),
LOAD_PERSONAL_INFO: type('[Session] Load Personal Info'),
LOAD_USER_ACCOUNT: type('[Session] Load User Account'),
RELOAD_PERSONAL_INFO: type('[Session] Reload Personal Info'),
CLEAR_USER_ACCOUNT: type('[Session] Clear User Account')
};
export class StandardSigninAction implements Action {
type = ActionTypes.STANDARD_SIGNIN;
constructor(public payload: Credentials) {
}
}
...
export type Actions
= StandardSigninAction
| LoadPersonalInfoAction
| ClearUserAccountAction
| ReloadPersonalInfoAction
| LoadUserAccountAction;
効果:ここ
は派遣しようとするコンポーネントである私は、コンポーネントが呼び出しを行い、デバッグで見ることができる@Effect()
standardSignin$: Observable<Action> = this.actions$
.ofType(session.ActionTypes.STANDARD_SIGNIN)
.map((action: StandardSigninAction) => action.payload)
.switchMap((credentials: Credentials) =>
this.sessionSigninService.signin(credentials)
.map(sessionToken => {
return new LoadPersonalInfoAction(sessionToken);
})
);
発送方法。コンストラクタ内のブレークポイントがヒットしたので、
StandardSigninAction
が実際にインスタンス化されていることも確認できます。
しかしstandardSignin$
効果が呼び出されない...
何がおそらく呼び出されていない効果を引き起こす可能性がありますか?
店内で起こっていることをどのようにデバッグできますか?
誰かが助けてくれますか?
P.S.次のように私は私の輸入では上記の効果を実行します:
EffectsModule.run(SessionEffects),
編集:ここに私のSessionSigninService.signin方法がある(観測を返さない)
signin(credentials: Credentials) {
const headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'});
const options = new RequestOptions({headers: headers});
const body = 'username=' + credentials.username + '&password=' + credentials.password;
return this.http.post(this.urls.AUTHENTICATION.SIGNIN, body, options).map(res => res.headers.get('x-auth-token'));
}
'@ ngrx'ライブラリの最新バージョンを使用していますか?あなたは働いている他の効果がありますか? 'SessionEffects'には他の効果がありますか? – cartant
はいセッションエフェクトには他の効果があります – balteo
誰かがngrxストア、エフェクト、アクションをデバッグする方法を提案できますか? – balteo