Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Last active October 7, 2017 19:15
Show Gist options
  • Save vzaidman/406c0268eeb0600e1c505b099b9aebcc to your computer and use it in GitHub Desktop.
Save vzaidman/406c0268eeb0600e1c505b099b9aebcc to your computer and use it in GitHub Desktop.
Creation of an Async Action Creator
export const fetchTodos = makeAsyncActionCreator('FETCH_TODOS')
fetchProfile()
// ⇒ { type: 'FETCH_PROFILE@ASYNC_REQUEST' }
fetchProfile.cancel())
// ⇒ { type: 'FETCH_PROFILE@ASYNC_CANCEL' }
fetchProfile.success(profile)
// ⇒ { type: 'FETCH_PROFILE@ASYNC_SUCCESS', payload: profile }
fetchProfile.failure(error)
// ⇒ { type: 'FETCH_PROFILE@ASYNC_FAILURE' payload: error }
fetchProfile.progress(progress)
// ⇒ { type: 'FETCH_PROFILE@ASYNC_PROGRESS', payload: progress }
dispatch(fetchProfile())
// ⇒ dispatch({ type: 'FETCH_PROFILE@ASYNC_REQUEST' }))
dispatch(fetchProfile.success(profile))
// ⇒ dispatch({ type: 'FETCH_PROFILE@ASYNC_SUCCESS', payload: profile })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment