import { ActionTypes } from "./actionTypes" ; import { ActionTypes as AppActionTypes } from '../actionTypes' ; import { AppStore } from "../store" ; import { Bundle } from "../linker" ; export interface Error { error : string ; source : string ; info : string ; } export const initialStateError = undefined ; export default function ( bundle ) { bundle . addReducer ( AppActionTypes . AppInit , ( state ) => { state . lastError = initialStateError ; } ) ; bundle . defineAction ( ActionTypes . Error ) ; bundle . addReducer ( ActionTypes . Error , ( state , { payload } ) => { console . log ( "GENERIC ERROR" , payload ) ; if ( payload . error ) { console . error ( payload . error ) ; } state . lastError = payload ; } ) ; bundle . defineAction ( ActionTypes . ErrorClear ) ; bundle . addReducer ( ActionTypes . ErrorClear , ( state ) => { state . lastError = initialStateError ; } ) ; }