import { pick } from "ramda" ; import { combineReducers , createStore } from "redux" ; import { notification , NotificationState } from "./notification/reducers" ; import { remember , RememberMeState } from "./remember-me/reducers" ; import { session , SessionState } from "./session/reducers" ; /**
 * Redux store state
 */ export interface State { notification : NotificationState ; remember : RememberMeState ; session : SessionState ; } param state export function dehydrate ( state ) { localStorage . setItem ( "state" , JSON . stringify ( { remember : pick ( [ "active" ] , state . remember ) , session : state . session ? pick ( [ "id" , "access" ] , state . session ) : null } ) ) ; } return export function rehydrate ( ) { return JSON . parse ( localStorage . getItem ( "state" ) || "{}" ) ; } /**
 * Redux store reducers
 */ export const reducers = combineReducers < State > ( { notification , remember , session } ) ; /**
 * Redux store
 */ export const store = createStore ( reducers , rehydrate ( ) ) ; store . subscribe ( ( ) => { dehydrate ( store . getState ( ) ) ; } ) ;