promiseReducer.js 418 B

1234567891011121314151617181920212223
  1. export function promiseReducer(state = {}, { type, name, status, payload, error }) {
  2. if (type === 'PROMISE') {
  3. return {
  4. ...state,
  5. [name]: { status, payload, error },
  6. }
  7. }
  8. if (type === 'PROMISE_CLEAR') {
  9. return {
  10. ...state,
  11. [name]: null,
  12. }
  13. }
  14. if (type === 'PROMISE_All_CLEAR') {
  15. return {
  16. state:null
  17. }
  18. }
  19. return state
  20. }