MCPcopy Create free account
hub / github.com/carbonplan/maps / reducer

Function reducer

src/loading/context.js:102–119  ·  view source on GitHub ↗
(state, action)

Source from the content-addressed store, hash-verified

100}
101
102const reducer = (state, action) => {
103 switch (action.type) {
104 case 'set':
105 action.loaders.forEach(({ id, key }) => {
106 state[key].add(id)
107 })
108
109 return { ...state }
110 case 'clear':
111 action.loaders.forEach(({ id, key }) => {
112 state[key].delete(id)
113 })
114
115 return { ...state }
116 default:
117 throw new Error(`Unexpected action: ${action.type}`)
118 }
119}
120
121export const LoadingProvider = ({ children }) => {
122 const [state, dispatch] = useReducer(reducer, {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected