Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | import { NgModule } from '@angular/core'; |
| 2 | import { NgReduxModule, NgRedux, DevToolsExtension } from '@angular-redux/store'; |
| 3 | import { RootEpics } from './epics'; |
| 4 | |
| 5 | import rootReducer, {AppState} from "./reducers"; |
| 6 | import {AAIEpics} from "../services/aaiService/aai.epics"; |
| 7 | |
| 8 | @NgModule({ |
| 9 | imports: [NgReduxModule], |
| 10 | providers: [RootEpics, AAIEpics], |
| 11 | }) |
| 12 | |
| 13 | export class StoreModule { |
| 14 | constructor( |
| 15 | public store: NgRedux<AppState>, |
| 16 | devTools: DevToolsExtension, |
| 17 | rootEpics: RootEpics, |
| 18 | ) { |
| 19 | |
| 20 | const persistedState = sessionStorage.getItem('reduxState') ? |
| 21 | JSON.parse(sessionStorage.getItem('reduxState')) : {}; |
| 22 | |
| 23 | store.configureStore( |
| 24 | rootReducer, |
| 25 | persistedState, |
| 26 | rootEpics.createEpics(), |
| 27 | devTools.isEnabled() ? [ devTools.enhancer() ] : []); |
| 28 | } |
| 29 | } |