@plone/volto
Version:
Volto
73 lines (71 loc) • 1.47 kB
JavaScript
const initialState = {
loaded: false,
loadState: {},
};
export default function asyncConnect(state = initialState, action = {}) {
const { key, data, error } = action;
switch (action.type) {
case '@redux-conn/BEGIN_GLOBAL_LOAD':
return {
...state,
loaded: false,
};
case '@redux-conn/END_GLOBAL_LOAD':
return {
...state,
loaded: true,
};
case '@redux-conn/LOAD':
return {
...state,
loadState: {
...state.loadState,
[]: {
loading: true,
loaded: false,
},
},
};
case '@redux-conn/LOAD_SUCCESS':
return {
...state,
loadState: {
...state.loadState,
[]: {
loading: false,
loaded: true,
error: null,
},
},
[]: data,
};
case '@redux-conn/LOAD_FAIL':
return {
...state,
loadState: {
...state.loadState,
[]: {
loading: false,
loaded: false,
error: error,
},
},
};
case '@redux-conn/CLEAR':
return {
...state,
loadState: {
...state.loadState,
[]: {
loading: false,
loaded: false,
error: null,
},
},
[]: null,
};
default:
break;
}
return state;
}