import { MenubarActions , RECEIVE_MENUBAR } from './menubar.actions' ; import { GeneralMenuItem } from './menubar.models' ; export interface MenubarState { menuItems : GeneralMenuItem [ ] | null ; } const initialState = { menuItems : null , } ; export function menubarReducer ( state = initialState , action ) { switch ( action . type ) { case RECEIVE_MENUBAR : console . log ( action ) ; return Object . assign ( { } , state , { menuItems : action . payload . map ( ( item ) => { return Object . keys ( item ) . reduce ( ( result , key ) => { if ( item [ key ] ) { result [ key ] = item [ key ] ; } return result ; } , { } ) ; } ) } ) ; default : return state ; } }