import { Injector } from "@angular/core" ; import type { MetaReducer } from "@ngrx/store" ; import { Store } from "@ngrx/store" ; import { NAVIGATION_ACTIONS , NOTIFICATION_ACTIONS } from "src/web/browser-window/app/store/actions" ; import { UnionOf } from "src/shared/ngrx-util" ; import { getWebLogger } from "src/web/browser-window/util" ; const logger = getWebLogger ( __filename ) ; export interface State { } export const reducers = { } ; export function createErrorHandlingMetaReducer ( injector ) { const result = ( reducer ) => { return ( state , action ) => { try { return reducer ( state , action ) ; } catch ( error ) { injector . get ( Store ) . dispatch ( NOTIFICATION_ACTIONS . Error ( error as Error ) ) ; } return state as State ; } ; } ; return result ; } export function createAppMetaReducer ( ) { const result = ( reducer ) => { return ( state , action ) => { if ( BUILD_ENVIRONMENT === "development" ) { if ( typeof action . type === "string" && action . type ) { logger . silly ( nameof ( createAppMetaReducer ) , action . type ) ; } } return reducer ( state , action ) ; } ; } ; return result ; }