import { Observable } from 'rxjs' ; import { Action } from '@ngrx/store' ; import { ActionWithPayload , CategoryActions } from '../actions' ; import { Category } from '../../../shared/model' ; export function categories ( state = [ ] , action ) { switch ( action . type ) { case CategoryActions . LOAD_CATEGORIES_SUCCESS : return action . payload ; default : return state ; } } export const getCategoryDictionary = ( state ) => { return ! state ? { } : state . reduce ( ( result , category ) => { result [ category . id ] = category ; return result ; } , { } ) ; } ; export function topCategories ( state = [ ] , action ) { switch ( action . type ) { case CategoryActions . LOAD_TOP_CATEGORIES_SUCEESS : return action . payload ; default : return state ; } }