[ ] Regression (a behavior that used to work and stopped working in a new release)
[*] Bug report
[ ] Feature request
[ ] Documentation issue or request
When trying to dispatch an action on ngInit, I am getting the following error messages:
Error: Effect "UserEffects.fetchUser$" dispatched an invalid action: undefined and TypeError: Actions must be objects after the dispatched action and the associated effect as executed.
To help those landing here from google, you probably returned store.dispatch(action) in your effect instead of simply the action, for example...
bad
@Effect()
loginSuccess$ = this.actions$.pipe(
ofType(UserApiActionTypes.LoginSuccess),
switchMap(_ => this.store$.select(fromAuth.getRedirectUrl)),
map(url => this.store$.dispatch(new routerActions.Go(url)))
);
good
@Effect()
loginSuccess$ = this.actions$.pipe(
ofType(UserApiActionTypes.LoginSuccess),
switchMap(_ => this.store$.select(fromAuth.getRedirectUrl)),
map(url => new routerActions.Go(url)) /* this is the changed line */
);
Most helpful comment
To help those landing here from google, you probably returned
store.dispatch(action)in your effect instead of simply the action, for example...bad
good