Skip to content
Snippets Groups Projects
withFetching.js 475 B
Newer Older
import { withStateHandlers } from 'recompose'

export default withStateHandlers(
  {
    fetchingError: '',
  },
  {
    setFetching: ({ isFetching }) => value => ({
      isFetching: value,
    }),
    toggleFetching: ({ isFetching }) => () => ({
      isFetching: !isFetching,
    }),
    setError: ({ fetchingError }) => e => ({
      fetchingError: e,
    }),
    clearError: ({ fetchingError }) => () => ({
      fetchingError: '',
    }),
  },
)