Skip to content

frontrockets/redux-abstract-action

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

This is part of @datarockets infrastructure

Install

yarn add @frontrockets/redux-abstract-action

Usage

import createAbstractAction from '@frontrockets/redux-abstract-action'

const fetch = createAbstractAction('Namespace/fetch', {
  // Here we specify functions which will generate a payload according to
  // arguments (we can specify generators for `init`, `success` and `failure`
  // actions)
  init: id => ({ id }),
  success: data => data,
})

fetch.init(10)
//- { type: 'Namespace/fetch/INIT', payload: { id: 10 } }

fetch.success({ name: 'Eugene' })
//- { type: 'Namespace/fetch/SUCCESS', payload: { name: 'Eugene' } }

fetch.failure()
//- { type: 'Namespace/fetch/FAILURE', payload: {} }

fetch.INIT
//- 'Namespace/fetch/INIT'

fetch.SUCCESS
//- 'Namespace/fetch/SUCCESS'

fetch.FAILURE
//- 'Namespace/fetch/FAILURE'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published