Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bang88/hake-redux
https://github.com/bang88/hake-redux
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bang88/hake-redux
- Owner: BANG88
- License: mit
- Created: 2017-03-23T09:07:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-08T07:34:13.000Z (almost 7 years ago)
- Last Synced: 2025-01-04T15:16:36.128Z (22 days ago)
- Language: TypeScript
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# hake-redux [![Build Status](https://travis-ci.org/bang88/hake-redux.svg?branch=master)](https://travis-ci.org/bang88/hake-redux)
> A promise middleware for redux, based on https://github.com/lelandrichardson/redux-pack
## Install
```sh
$ npm install --save hake-redux# or
$ yarn add hake-redux
```## Usage
```js
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 :
```js
// 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](https://github.com/lelandrichardson/redux-pack#redux-pack)
## License
MIT © [bang](https://github.com/bang88) [lelandrichardson](https://github.com/lelandrichardson/redux-pack)