我有一個使用ngrx/effects庫定義的非常直接的效果。ngrx/effects不調度映射動作
@Effect()
public Authorize$ = this._actions$.ofType(IdentityActionsService.AUTHORIZE_IDENTITY)
.switchMap(action => this._svc.Authorize$(action.payload))
.catch(err => Observable.of(null).do(() => console.error(err); }))
.map(identity => this._identity.OnIdentityAuthorized(identity))
的@Effect被觸發,授權$()運行,而OnIdentityAuthorized()方法,該方法返回一個動作({類型:有效載荷:})火災...
我期待什麼發生的是由OnIdentityAuthorized()返回的動作應該被送入相應的reducer - 這不會發生。
我在OnIdentityAuthorized和相應的reducer中調試器調用。 OnIdentityAuthorized返回的Action沒有被調度。什麼可能導致這個?我誤解了什麼嗎?
我覺得我已經得到了基本相同例子1瀏覽:https://github.com/ngrx/effects/blob/master/docs/intro.md
編輯 增加額外的代碼段...效果觸發OnIdentityAuthorized調試程序語句,因此可觀察到的是發射全部通過異步授權調用的方式。減速器殼體,不會觸發...
這裏是OnIdentityAuthorized()實現:
public static ON_IDENTITY_AUTHORIZED = '[IDENTITY] Authorized';
public OnIdentityAuthorized(identity: Identity | JWT): Action {
debugger;
return {
type: IdentityActionsService.ON_IDENTITY_AUTHORIZED,
payload: identity
};
}
這裏是減速器部:
switch (action.type) {
case IdentityActionsService.ON_IDENTITY_AUTHORIZED:
debugger;
return merge({}, action.payload);
「this._identity.OnIdentityAuthorized(identity)'的返回值是什麼?你可以發佈該方法和示例內容嗎? – olsn
已更新,其中包含請求的信息。 –