Newfoundland Pitbull Mix

    redux-thunk-action-helpers

    1.0.1 • Public • Published

    npm version Build Status Coverage Status Inline docs Hit Count Build Dependencies Dev Dependencies

    NPM

    contributions welcome

    Installation

    install

    $ npm i redux-thunk-action-helpers 
    $ yarn add redux-thunk-action-helpers

    Motivation

    Thunk actions usually follow the same rules. Dispatch start action, run some code, dispatch the result on the sucess action or dispatch the error on the fail action

    Example

    action types

    import { createActionTypes } from 'redux-thunk-action-helpers';
    
    export const userActionTypes = createActionTypes('my-app', 'FETCH', 'SUBMIT');
    
    /*
     * userActionTypes = {
     *  FETCH : '@@my-app/FETCH',
     *  FETCH_START : '@@my-app/FETCH_START',
     *  FETCH_SUCCESS : '@@my-app/FETCH_SUCCESS',
     *  FETCH_ERROR : '@@my-app/FETCH_ERROR',
     *  SUBMIT : '@@my-app/SUBMIT',
     *  SUBMIT_START : '@@my-app/SUBMIT_START',
     *  SUBMIT_SUCCESS : '@@my-app/SUBMIT_SUCCESS',
     *  SUBMIT_ERROR : '@@my-app/SUBMIT_ERROR',
     * }
     */
    
    

    action creator

    import { createActionCreator } from 'redux-thunk-action-helpers';
    
    export const doFetchUsers = createActionCreator('GET_USERS', (page, limit) => api.getUsers(page, limit));
    
    

    API

    createActionTypes(namespace, ...types);


    createActionCreator(type, fn);

    fn = (...args, { dispatch, getState, extra }) => Promise/Value

    License

    MIT

    Install

    npm i redux-thunk-action-helpers

    DownloadsWeekly Downloads

    4

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    8.92 kB

    Total Files

    15

    Last publish

    Collaborators

    • kamikazept