0
votes

I've got a pretty straight forward effect defined using the ngrx/effects library.

@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)) 

The @Effect is triggered, authorize$() runs, and the OnIdentityAuthorized() method, which returns an Action ({type: payload: }) fires...

What I expect to happen is that the action returned by OnIdentityAuthorized() should get fed into the appropriate reducer - that is not happening.

I have a debugger call in OnIdentityAuthorized and in the corresponding reducer. The Action returned by OnIdentityAuthorized is not being dispatched. What might cause this? Am I misunderstanding something?

I feel like what I've got is basically identical to example 1 here: https://github.com/ngrx/effects/blob/master/docs/intro.md

EDIT Added additional code sections... The effect triggers the OnIdentityAuthorized debugger statement, so the observable is emitting all the way through the async authorization call. The reducer case is not triggered...

Here is the OnIdentityAuthorized() implementation:

public static ON_IDENTITY_AUTHORIZED = '[IDENTITY] Authorized';
public OnIdentityAuthorized(identity: Identity | JWT): Action {
    debugger;
    return {
         type: IdentityActionsService.ON_IDENTITY_AUTHORIZED,
         payload: identity
    };
}

Here is the reducer section:

switch (action.type) {
        case IdentityActionsService.ON_IDENTITY_AUTHORIZED:
            debugger;
            return merge({}, action.payload);
1
What's the return-value of this._identity.OnIdentityAuthorized(identity)? Can you post the method and an example content?olsn
Updated to include requested info.josh-sachs

1 Answers

0
votes

Turns out to have been an issue with the way I was registering the reducers.

I was trying to do something exotic in order to add additional state endpoints for lazy loaded modules... turns out there is an issue there - but that is a different question.