hake-redux
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

hake-redux Build Status

A promise middleware for redux, based on https://github.com/lelandrichardson/redux-pack

Install

$ npm install --save hake-redux
 
# or 
 
$ yarn add hake-redux

Usage

import { createStore, applyMiddleware } from 'redux'
import hakeReduxMiddleware from 'hake-redux'
import rootReducer from './reducer'
// axios is a xhr lib just like fetch.
import axios from 'axios'
// your client
const client = axios.create()
// store
const store = createStore(
  rootReducer,
  applyMiddleware(hakeReduxMiddleware(client))
)
 

API

The difference between redux-pack and hake-redux is :

// actions.js
export function loadFoo(id) {
  return {
    type: LOAD_FOO,
    // redux-pack way
    // promise: Api.getFoo(id),
    // hake-redux doing.
    promise: client => client.get('/path/to/foo')
    meta: {
        onSuccess: (response) => logSuccess(response)
    },
  };
}

Redux-Pack documentation

License

MIT © bang lelandrichardson

Readme

Keywords

Package Sidebar

Install

npm i hake-redux

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

17.6 kB

Total Files

18

Last publish

Collaborators

  • bang88