1.0.0 • Published 8 years ago

create-promise-action-factory v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Create promise action factory

Attention! This package created only for test application.

This package helps to dispatch async actions.

Installation

npm install create-promise-action-factory --save

Usage

For correct package working use ES6 transpailer as babeljs

Create your action creators by factory usage like the followings:

import {factory as actionCreatorFactory} from 'create-promise-action';
import axios from 'axios';

const loadUser = actionCreatorFactory('LOAD', (state, payload) => {
    return axios.get('/api/userId', payload);
});

loadUser({userId: 1});

Also to apply promise middleware in your redux store:

import {createStore, applyMiddleware, compose} from 'redux';
import {middleware as promiseMiddleware} from 'create-promise-action';

const initialState = {/* .. */};

const enhancer = compose(
  // ..
  applyMiddleware(promiseMiddleware),
  // ..
);

const store = createStore(rootReducer, initialState, enhancer);
1.0.0

8 years ago

1.1.0

8 years ago