All Projects β†’ Wolox β†’ redux-recompose

Wolox / redux-recompose

Licence: other
A Redux utility belt for reducers and actions. Inspired by acdlite/recompose.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to redux-recompose

React Hook Thunk Reducer
πŸ“‘ A React useReducer() hook whose dispatcher supports thunks Γ  la redux-thunk.
Stars: ✭ 91 (+30%)
Mutual labels:  reducer
Redux
No description or website provided.
Stars: ✭ 40 (-42.86%)
Mutual labels:  reducer
redux-lightweight
Write one business logic instead of writing actions, action types and reducers
Stars: ✭ 41 (-41.43%)
Mutual labels:  reducer
Juicr.js
A simple (and tiny <1kb) redux inspired reducer for handling state changes.
Stars: ✭ 102 (+45.71%)
Mutual labels:  reducer
redux-tools
πŸ’ͺ Maintaining large Redux applications with ease.
Stars: ✭ 34 (-51.43%)
Mutual labels:  reducer
redux-reducer-async
Create redux reducers for async behaviors of multiple actions.
Stars: ✭ 14 (-80%)
Mutual labels:  reducer
Lithium
Line-based testcase reducer
Stars: ✭ 80 (+14.29%)
Mutual labels:  reducer
redux-leaves
Write once. Reduce anywhere.
Stars: ✭ 52 (-25.71%)
Mutual labels:  reducer
redux-entities
Higher-order reducer for store entities received from normalizr and makes it easy to handle them.
Stars: ✭ 34 (-51.43%)
Mutual labels:  reducer
redux-interactions
Composing UI as a set of interactions
Stars: ✭ 22 (-68.57%)
Mutual labels:  reducer
Clean State
🐻 A pure and compact state manager, using React-hooks native implementation, automatically connect the module organization architecture. πŸ‹
Stars: ✭ 107 (+52.86%)
Mutual labels:  reducer
Deox
Functional Type-safe Flux Standard Utilities
Stars: ✭ 200 (+185.71%)
Mutual labels:  reducer
wor-authentication
Gem to add authentication to your application using JWT, with expirable, renewable and customizable tokens!
Stars: ✭ 63 (-10%)
Mutual labels:  wolox
Use Substate
πŸ™ Lightweight (<600B minified + gzipped) React Hook to subscribe to a subset of your single app state.
Stars: ✭ 97 (+38.57%)
Mutual labels:  reducer
redux-fp
Functional programming helpers for Redux.
Stars: ✭ 28 (-60%)
Mutual labels:  reducer
Xstateful
A wrapper for xstate that stores state, handles transitions, emits events for state changes and actions/activities, and includes an optional reducer framework for updating state and invoking side-effects
Stars: ✭ 81 (+15.71%)
Mutual labels:  reducer
react-redux-spinner
An automatic spinner for react and redux
Stars: ✭ 81 (+15.71%)
Mutual labels:  reducer
hermes-js
Universal action dispatcher for JavaScript apps
Stars: ✭ 15 (-78.57%)
Mutual labels:  reducer
flow-state
UI state management with RxJS.
Stars: ✭ 33 (-52.86%)
Mutual labels:  reducer
ngx-redux-core
The modern redux integration for Angular 6+
Stars: ✭ 32 (-54.29%)
Mutual labels:  reducer

versiΓ³n npm Download npm codecov supported by

Redux-recompose

Vertical Logo Redux-recompose

Why another Redux library ?

redux-recompose provide tools to write less reducers/actions code.

Here is a blog post about it.

Usually, we are used to write:

// actions.js

function increment(anAmount) {
  return { type: 'INCREMENT', payload: anAmount };
}

// reducer.js

function reducer(state = initialState, action) {
  switch(action.type) {
    case 'INCREMENT':
      return { ...state, counter: state.counter + action.payload };
    default:
      return state;
  }
}

With the new concept of target of an action, we could write something like:

// actions.js

// Define an action. It will place the result on state.counter
function increment(anAmount) {
  return { type: 'INCREMENT', target: 'counter', payload: anAmount };
}


// reducer.js
// Create a new effect decoupled from the state structure at all.
const onAdd = (state, action) => ({ ...state, [action.target]: state[action.target] + action.payload });

// Describe your reducer - without the switch
const reducerDescription = {
  'INCREMENT': onAdd()
}

// Create it !
const reducer = createReducer(initialState, reducerDescription);

Effects

Effects are functions that describe how the state changes, but are agnostic of what part of the state is being changed.

redux-recompose provides some effects to ease reducer definitions. These are:

New effects are welcome ! Feel free to open an issue or even a PR.

Creators

There are a few creators that also ease writing Redux reducers and async actions.

Since state handling is decoupled from its state, we could create some more complex async actions, or even map an effect with an action type to create families of actions.
More crazy and useful ideas are welcome too!

Completers

You could use completers to reduce your code size. Completers are functions that take partial definitions (i.e. descriptors) and help to construct the whole definition.

Completers in general looks like this:

  • A pattern is being repeated in an element.
  • Identify that pattern and try to apply to every element similar to those who use this pattern, although they apply it or not.
  • Add some exceptions for elements who don't use this pattern.
  • Compress your code size by applying that pattern to all elements but not for exception cases.

There are a few completers that can be used:

Injectors

There's currently documentation for the following:

Middlewares

Middlewares allow to inject logic between dispatching the action and the actual desired change in the store. Middlewares are particularly helpful when handling asynchronous actions.

The following are currently available:

Using with immutable libraries

The way redux-recompose updates the redux state can be configured. The default configuration is

(state, newContent) => ({ ...state, ...newContent })

You can use configureMergeState to override the way redux-recompose handles state merging. This is specially useful when you are using immutable libraries. For example, if you are using seamless-immutable to keep your store immutable, you'll want to use it's merge function. You can do so with the following configuration:

import { configureMergeState } from 'redux-recompose';

configureMergeState((state, newContent) => state.merge(newContent))

Recipes

Thanks to

This library was inspired by acdlite/recompose. Let's keep creating tools for ease development.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

This project was written by Manuel Battan and it is maintained by Wolox.

Wolox

License

redux-recompose is available under the MIT license.

Copyright (c) 2017 Manuel Battan <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].