import { Action , createReducer , on } from '@ngrx/store' ; import { changeAnimationsElements , changeAnimationsPage , changeAnimationsPageDisabled , changeTheme , setIsMobile , setSidenav , setSidenavFromPage , toggleSidenav , } from './actions' ; import { State } from './model' ; export const initialState = { showSidenav : false , isMobile : true , theme : 'dark-theme' , pageAnimations : true , pageAnimationsDisabled : false , elementsAnimations : true , } ; export const factory = createReducer < State > ( initialState , on ( setSidenav , setSidenavFromPage , ( state , { showSidenav } ) => ( { ... state , showSidenav , } ) ) , on ( toggleSidenav , state => ( { ... state , showSidenav : ! state . showSidenav , } ) ) , on ( setIsMobile , ( state , { isMobile } ) => ( { ... state , isMobile , showSidenav : ! isMobile , } ) ) , on ( changeTheme , changeAnimationsElements , changeAnimationsPage , ( state , payload ) => ( { ... state , ... payload , } ) ) , on ( changeAnimationsPageDisabled , ( state , { pageAnimationsDisabled } ) => ( { ... state , pageAnimationsDisabled , pageAnimations : false , } ) ) ) ; export function reducer ( state , action ) { return factory ( state , action ) ; }