import * as apiAction from '../actions/api' ; import * as trendsAction from '../actions/trends' ; prop export interface State { loading : boolean ; } prop export const initialState = { loading : false , } ; /**
 * The actual reducer function. Reducers can be thought of as the tables in the DataBase.
 * These are the functions which are responsible for maintaing, and updating the
 * `State` of the application they control.
 *
 * Here the reducer cotrols that part of the state which is shows the state of the application
 * wheather it is searching and what is it searching for.
 */ export function reducer ( state = initialState , action ) { switch ( action . type ) { case trendsAction . ActionTypes . SEARCH_TRENDING_HASHTAGS : { return Object . assign ( { } , state , { loading : true } ) ; } case apiAction . ActionTypes . SEARCH_TRENDING_HASHTAGS_SUCCESS : case apiAction . ActionTypes . SEARCH_COMPLETE_FAIL : { return Object . assign ( { } , state , { loading : false } ) ; } default : { return state ; } } } /**
 * Because the data structure is defined within the reducer it is optimal to
 * locate our selector functions at this level. If store is to be thought of
 * as a database, and reducers the tables, selectors can be considered the
 * queries into said database. Remember to keep your selectors small and
 * focused so they can be combined and composed to fit each particular
 * use-case.
 */ export const getLoading = ( state ) => state . loading ;