New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

repatch

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repatch - npm Package Compare versions

Comparing version 0.0.13 to 1.0.0

2

package.json
{
"name": "repatch",
"version": "0.0.13",
"version": "1.0.0",
"description": "Dispatch reducers",

@@ -5,0 +5,0 @@ "main": "lib/store/index",

@@ -5,7 +5,7 @@ # Repatch

The most of redux projects do not need sctrict action administration. Action types, action creators and reducers' action handlers are mutually assigned to each other.
[Redux](https://www.npmjs.com/package/redux) has a verbose action management. The most of redux projects do not need sctrict action administration. Action types, action creators and the reducer's action handlers are mutually assigned to each other. Repatch's purpose is creating actions briefly.
The simplest way to keep immutable action controlled dataflow is dispatching pure functions (as reducers) to the store.
So we have only actions which return reducers.
In this terminology action is a function that returns a reducer.

@@ -20,2 +20,8 @@ ```javascript

Following this thread an inline action looks like this:
```javascript
dispatch(state => ({ ...state, isFetching: true }))
```
## Installation

@@ -27,2 +33,7 @@

## Examples
- [JavaScript example](https://github.com/jaystack/repatch-example-electron-app)
- [TypeScript example](https://github.com/jaystack/repatch-example-electron-app-ts)
## How to use

@@ -52,34 +63,18 @@

## Subreducers
## Sub-reducers
We do not need to reduce always the whole state of the store. A good practice to avoid this effort is using subreducers.
We do not need to reduce always the whole state of the store. A good practice to avoid this effort is using sub-reducers.
Let's suppose we have the following state:
```javascript
const store = new Store({
userManagement: {
users: [...],
isFetching: false,
error: null
const reduceFoo = reducer => state => ({
...state,
bar: {
...state.bar,
foo: reducer(state.bar.foo)
}
});
```
Then we can make a subredcer for the `userManagement` section:
```javascript
const reduceUserManagement = reducer => state => ({
...state,
userManagement: reducer(state.userManagement)
});
const fooAction = payload => reduceFoo(state => ({ ...state, ...payload }));
```
After that reducing only the `userManagement` state it's easy:
```javascript
const rejectFetchingUsers = error =>
reduceUserManagement(state => ({ ...state, error, isFetching: false }));
```
## Middlewares

@@ -167,5 +162,7 @@

const state = { name: 'hello' };
const nextState = changeName('hi')(state);
assert.strictEqual(nextState.name, 'hi');
it('changeName', () => {
const state = { name: 'john' };
const nextState = changeName('jack')(state);
assert.strictEqual(nextState.name, 'jack');
});
```

@@ -172,0 +169,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc