Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
redux-recompose
Advanced tools
A Redux utility belt for reducers and actions. Inspired by acdlite/recompose.
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 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:
We are currently writing some other effects:
onReset
onToggle
onCycle
onMap
And other utilities like
composeEffects
New effects are welcome ! Feel free to open an issue or even a PR.
There are a few creators that also ease writing Redux reducers and async actions.
We are currently working on these creators:
createMultiTargetedAction
createPollingAction
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 !
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:
There are a few completers that can be used:
We are working to introduce other completers like:
completeFromProps: Helps to write a state from propTypes definition
And to introduce completers that support custom patterns:
const initialStateDescription = { msg: '' };
const initialState = completeCustomState(initialStateDescription, ['Info', 'Warn', 'Error']);
// initialState.toEqual({ msg: '', msgInfo: '', msgWarn: '', msgError: '' });
Injectors are meant to customize your thunk action behavior. We are working on these:
withFailure
withFlowDetermination
withPostFailure
withPostFetch
withPostSuccess
withPrefetch
withStatusHandling
withSuccess
There's currently documentation for the following:
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:
This library was inspired by acdlite/recompose. Let's keep creating tools for ease development.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)This project is maintained by Manuel Battan and it was written by Wolox.
redux-recompose is available under the MIT license.
Copyright (c) 2017 Manuel Battan <manuel.battan@wolox.com.ar>
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.
FAQs
A Redux utility belt for reducers and actions. Inspired by acdlite/recompose.
We found that redux-recompose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 28 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.