A simple action and reducer utilizing createNamespaceReducer
for reusability and simple writing of a reducer.
import { createNamespaceReducer, createReducer } from '@ghadyani-framework/redux-utils'
import {
LOADED,
LOADING,
} from './actions'
export const initialState = false
export const reducerActions = {
[LOADED]: () => initialState,
[LOADING]: () => true,
}
const isLoadingReducer = (
createReducer(
reducerActions,
initialState,
)
)
export default (
createNamespaceReducer(
isLoadingReducer,
)
)
export const LOADED = 'INDICATORS::LOADED'
export const LOADING = 'INDICATORS::LOADING'
export const setLoaded = (
namespace,
) => ({
namespace,
type: LOADED,
})
export const setLoading = (
namespace,
) => ({
namespace,
type: LOADING,
})