Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/doodledood/redux-fx

A library to manage side effects for Redux based on the Elm Architecture
https://github.com/doodledood/redux-fx

Last synced: about 2 months ago
JSON representation

A library to manage side effects for Redux based on the Elm Architecture

Awesome Lists containing this project

README

        

THIS LIBRARY IS CURRENTLY NOT MAINTAINED

redux-fx



NPM Version


Coverage Status


Build Status


Downloads


Dependency Status


License


A library for managing side effects for Redux, inspired by the Elm Architecture.

## Install

```sh
npm install redux-fx
```

## Usage

```js
import {enhanceStoreWithEffects, fx} from "redux-fx"

...

// Decorate createStore with enhanceStoreWithEffects to enable support for effects
const createStoreWithMiddleware = compose(
applyMiddleware(someMiddleware),
devTools(),
enhanceStoreWithEffects()
)(createStore);

...

// Create effects of signature (any) => (dispatch, getState) => (any)
const incrementWithDelay = seconds => dispatch => setTimeout(() => dispatch({type: "INCREMENT"}), seconds * 1000);

...

// Return a [state,effect] tuple to create effect descriptors that are fully testable.
const reducer = (state, action) => {
switch (action.type) {
case "INCREMENT":
return [{count: state.count + 1}, fx(incrementWithDelay, 1)];
case "DECREMENT":
return {count: state.count - 1};
default:
return state;
}
};

```

## License

MIT © [doodledood](http://github.com/doodledood)

[npm-url]: https://npmjs.org/package/redux-fx
[npm-image]: https://img.shields.io/npm/v/redux-fx.svg?style=flat-square

[travis-url]: https://travis-ci.org/doodledood/redux-fx
[travis-image]: https://img.shields.io/travis/doodledood/redux-fx.svg?style=flat-square

[coveralls-url]: https://coveralls.io/r/doodledood/redux-fx
[coveralls-image]: https://img.shields.io/coveralls/doodledood/redux-fx.svg?style=flat-square

[depstat-url]: https://david-dm.org/doodledood/redux-fx
[depstat-image]: https://david-dm.org/doodledood/redux-fx.svg?style=flat-square

[download-badge]: http://img.shields.io/npm/dm/redux-fx.svg?style=flat-square