Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/launchpadlab/lp-redux-utils
A collection of redux helper functions.
https://github.com/launchpadlab/lp-redux-utils
Last synced: 3 days ago
JSON representation
A collection of redux helper functions.
- Host: GitHub
- URL: https://github.com/launchpadlab/lp-redux-utils
- Owner: LaunchPadLab
- License: mit
- Created: 2017-10-06T18:03:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-11T17:53:05.000Z (6 months ago)
- Last Synced: 2024-09-21T21:40:13.593Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/%40launchpadlab%2Flp-redux-utils.svg)](https://badge.fury.io/js/%40launchpadlab%2Flp-redux-utils)
# lp-redux-utils
A collection of utility functions for redux applications. These helpers can help reduce boilerplate when accomplishing common redux tasks. Designed to be used in tandem with [redux-actions](https://github.com/redux-utilities/redux-actions).
The key helpers in this library are:
- `setState(path)`: set a value in state when an action is dispatched.
- `unsetState(path)`: clear a value in state when an action is dispatched.
- `selectorForSlice(path)`: create a `select` function that can be used to create nested selectors for a path.```js
import { setState, selectorForSlice } from '@launchpadlab/lp-redux-utils'
import { createAction, handleActions } from 'redux-actions'// Generic setter from redux-actions
const setUser = createAction('SET_USER')const reducer = handleActions(
{
// Set a value in state when the action is dispatched
[setUser]: setState('stuff.user'),
},
{}
)// Create selectors for nested values
const select = selectorForSlice('stuff')
const userSelector = select('user')// userSelector(state) ->
```## Documentation
Documentation and usage info can be found in [docs.md](docs.md).
## Contribution
This package follows the Opex [NPM package guidelines](https://github.com/LaunchPadLab/opex/blob/master/gists/npm-package-guidelines.md). Please refer to the linked document for information on contributing, testing and versioning.