logout() { this.ngRedux.dispatch({type: 'RESET_BOARD_STORE'}); this.ngRedux.dispatch({type: 'RESET_USER_STORE'}); this.ngRedux.dispatch({type: 'RESET_CARD_STORE'}); this.ngRedux.dispatch({type: 'RESET_LIST_STORE'}); this.ngRedux.dispatch({type: 'REMOVE_BOARD_PREFERENCES'}); localStorage.removeItem('token'); this.router.navigate(['/start']); }
this.userRef.valueChanges().subscribe((u: IUser) => { if(u) { this.user = u; this.user.userId = this.userId; let cats = !this.user.categories ? [] : this.user.categories; this.ngRedux.dispatch({type: Actions.LOAD_USER, user: this.user}); this.ngRedux.dispatch({type: Actions.LOAD_CATEGORIES, categories: cats}); } });
constructor(private ngRedux: NgRedux<IAppState>, private router: Router, private userEpics: UserEpics, private profileEpics: ProfileEpics, private quotesEpics: QuotesEpics, private usersEpics: UsersEpics) { const epics = [ this.userEpics.signin, this.userEpics.signup, this.userEpics.resetPassword, this.userEpics.changePassword, this.profileEpics.fetchUser, this.profileEpics.updateUser, this.quotesEpics.fetchQuotes, this.quotesEpics.saveQuote, this.quotesEpics.updateQuoteModal, this.quotesEpics.updateQuote, this.quotesEpics.removeQuote, this.quotesEpics.recommendQuote, this.quotesEpics.unrecommendQuote, this.usersEpics.fetchUsers, this.usersEpics.followUser, this.usersEpics.unfollowUser, ]; const epicsMiddlewares = epics.reduce((acc: any[], epic: any) => acc.concat(createEpicMiddleware(epic)), []); ngRedux.configureStore(rootReducer, {}, [...middlewares, ...epicsMiddlewares], enhancers); }
beforeEach(inject([NgRedux], (store: NgRedux<AppState>) => { const action = commandGelungen( {type: CommandType.BeginneInventur, payload: {id: '4711'}, meta: {}}, {status: 200, message: 'OK'}) store.dispatch(action) }))
constructor( private ngRedux: NgRedux<IAppState>, private devTool: DevToolsExtension, private rootEpic: RootEpic, private router: Router, ) { const middleware = [ createEpicMiddleware(this.rootEpic.combineAll()), createLogger(), ]; const reducer = compose( mergePersistedState() )(rootReducer); const storage = compose( filter('auth') )(adapter(window.localStorage)); const enhancers = [ persistState(storage, 'fyibn/store'), ]; if (devTool.isEnabled()) { enhancers.push(devTool.enhancer()); } this.ngRedux.configureStore( reducer, {} as IAppState, middleware, enhancers, ); }
getCourses() { let coursesFetchedData: ICourse[] = [ { id: 1, name: 'Learning Flux', topic: 'Flux', }, { id: 2, name: 'Learning Angular2', topic: 'Angular2', }, { id: 3, name: 'Using Redux with Angular2', topic: 'Angular2', } ]; // store.dispatch({ // type: 'GET_COURSES_SUCCESS', // coursesFetchedData // }); /* note: in advanced version, this will be its own layer/injectable service - removed from Ng Data/http services */ this.ngRedux.dispatch({ type: 'GET_COURSES_SUCCESS', coursesFetchedData, }); };
ngOnInit() { let options = this.storeId? this.ngRedux.getState()[this.storeId].options : this.ngRedux.getState().options; if(options && options[this.option]){ this.active = true } }
constructor(ngRedux: NgRedux<IAppState>) { // Tell @angular-redux/store about our rootReducer and our initial state. // It will use this to create a redux store for us and wire up all the // events. ngRedux.configureStore( rootReducer, INITIAL_STATE); }
beginneInventur(id: any) { this.command.send( CommandType.BeginneInventur, {id: id}, {}); const state = this.store.getState(); }
this.geolocationCoordinates$.subscribe((location: GeoJSON.Position) => { this.currentLocation = location; // If it is the first view, then set the current center if (this.ngRedux.getState().firstView && location) { this.center = location; } });