1.0.0 • Published 6 years ago

redux-dynamics v1.0.0

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

Package version Build Status Coverage Status Dependencies Status

redux-dynamics

Strongly-typed collection of useful tools to make your Redux workflow more dynamic.

Features

Reducers

  • No huge switch statements!
  • state is always immutable
  • action is always immutable
  • context shared between all subscriptions
  • Declarative reducer subscriptions to the actions
  • Encouraging pure resolver functions
  • Support of RegExp as the expected action type

Getting started

Install

NPM:

npm install redux-dynamics --save

Yarn:

yarn add redux-dynamics

Create a reducer

// ./store/comments/index.js
import { Reducer } from 'redux-dynamics';

/* Create a new reducer with initial state */
const reducer = new Reducer({
  likes: 0
});

/* Subscribe to different actions */
reducer.subscribe('ADD_LIKE', (state, action, context) => {
  /* Note how both "state" and "action" are immutable */
  const nextLikes = state.get('likes') + action.get('amount');

  /* Resolve the next state */
  return state.set('likes', nextLikes);
});

reducer.subscribe('ACTION_TYPE', (state, action, context) => state);

export default reducer;

Connect to Redux

// ./store/reducer.js
import { createReducer } from 'redux';
import commentsReducer from './comments';

export default createReducer({
  /* Convert "Reducer" class into pure reducer function */
  comments: commentsReducer.toFunction()
});

Documentation

For more details on methods, usage examples and troubleshooting see the Documentation.

Contributing

Feel free to submit your ideas on enhanced Redux workflow by issuing a Pull request.

In case you have discovered a bug, outdated documentation or any other mismatch, please create a new Issue.

License

This library is licensed under MIT license.

1.0.0

6 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago