You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.1 KiB

// ------------------------------------
// Initial State
// ------------------------------------
const initialState = {
isLoading: true
}
// ------------------------------------
// Constants
// ------------------------------------
export const SET_LOADING = 'SET_LOADING'
// ------------------------------------
// Actions
// ------------------------------------
export function setLoading(isLoading) {
return {
type: SET_LOADING,
isLoading
}
}
// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
[SET_LOADING]: (state, { isLoading }) => ({ ...state, isLoading })
}
// ------------------------------------
// Selectors
// ------------------------------------
const loadingSelectors = {}
loadingSelectors.isLoading = state => state.loading.isLoading
export { loadingSelectors }
// ------------------------------------
// Reducer
// ------------------------------------
export default function loadingReducer(state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]
return handler ? handler(state, action) : state
}