https://github.com/launchpadlab/lp-redux-utils
A collection of redux helper functions.
https://github.com/launchpadlab/lp-redux-utils
Last synced: 8 months 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-12T20:09:09.000Z (11 months ago)
- Last Synced: 2025-05-19T18:16:42.955Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 20
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](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.