1.0.12 • Published 10 years ago

redux-fx v1.0.12

Weekly downloads
4
License
MIT
Repository
github
Last release
10 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

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago