I have moved own project to angular 6, @angular-redux/store 9 from 5 version. All was fine, but way for registrate epics in middleware not worked. I remove all epics from middleware except logger and startup was fine with all actions executed. Then i try add one epic and get error like
TypeError: action$.pipe is not a function
at SecurityUserEpics.loadSecurityUser (security-user.epic.ts:31)
at combineEpics.js:19
Then i try to solve this and search many examples and docs about, but cant find solution. After deciding to ask question here and while prepare code for question the solution was found. Soo, i post here that solution in hope that this will save time for someone. epic:
loadSecurityUser = (action$) => {
debugger;
// here i have object of type : {getState: ƒ, dispatch: ƒ} and thats was pain from older version. pipe helps!
return action$.pipe(
ofType(SecurityUserActions.LoadSecurityUsers),
switchMap(q => this._dataSrv.getUserInfo()
.pipe(map(data => {
localStorage.setItem('isNeedRelogin', '0');
return this._securityUserActions.loadSecurityUserComplete(data);
}))));
}
And final config store:
const epicMiddleware = createEpicMiddleware();
const middleware = [epicMiddleware];
middleware.push(createLogger());
ngRedux.configureStore(combinedReducer, INITIAL_STATE, middleware, storeEnhancers);
const rootEpic = combineEpics(this._securityUserEpics.loadSecurityUser);
// this is new way of middleware registration
epicMiddleware.run(rootEpic);