import * as paginationAction from '../actions/pagination' ; prop export interface State { page : number ; pageLoading : boolean ; pagesAvailable : boolean ; } prop export const initialState = { page : 0 , pageLoading : false , pagesAvailable : true } ; /**
 * 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 paginationAction . ActionTypes . NEXT_PAGE : { return Object . assign ( { } , state , { page : state . page + 1 , pageLoading : true } ) ; } case paginationAction . ActionTypes . PAGINATION_COMPLETE_SUCCESS : { return Object . assign ( { } , state , { pageLoading : false , pagesAvailable : ( action . payload . statuses . length < 20 ? false : true ) , } ) ; } case paginationAction . ActionTypes . PAGINATION_COMPLETE_FAIL : { return Object . assign ( { } , state , { page : state . page - 1 , pageLoading : false , pagesAvailable : false } ) ; } case paginationAction . ActionTypes . REVERT_PAGINATION_STATE : { return Object . assign ( { } , state , { pageLoading : false , pagesAvailable : true } ) ; } 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 getPage = ( state ) => state . page ; export const getPageLoading = ( state ) => state . pageLoading ; export const getPagesAvailable = ( state ) => state . pagesAvailable ;