1.0.12 • Published 8 years ago

redux-fx v1.0.12

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

redux-fx

Install

npm install redux-fx

Usage

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

...

// Decorate createStore with enhanceStoreWithEffects to enable support for effects 
// NOTE: the enhancer HAS to come last in order for other enhancers to work
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

1.1.0

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago