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 1.0.1 to 1.0.2

2

package.json
{
"name": "repatch",
"version": "1.0.1",
"version": "1.0.2",
"description": "Dispatch reducers",

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

@@ -10,14 +10,14 @@ # Repatch

```javascript
dispatch(state => ({ ...state, isFetching: true }));
store.dispatch(state => ({ ...state, counter: state.counter + 1 }));
```
In this terminology action is a function that returns a reducer.
**In this terminology action is a function that returns a reducer:**
```javascript
const selectUser = userId => state => ({
const increment = amount => state => ({
...state,
selectedUser: userId
counter: state.counter + amount
});
dispatch(selectUser(123));
store.dispatch(increment(42));
```

@@ -41,3 +41,3 @@

const store = new Store(<initialState>);
const store = new Store(initialState);
```

@@ -63,14 +63,18 @@

We do not need to reduce always the whole state of the store. A good practice to avoid this effort is using sub-reducers.
We do not need to reduce always the whole state of the store. Repatch also offers a way to combine sub-reducers, those describe a deeply nested property in the state. We just define a function that takes a nested reducer as argument, and returns a reducer that reduces the whole state:
```javascript
const reduceFoo = reducer => state => ({
const reduceFoo = fooReducer => state => ({
...state,
bar: {
...state.bar,
foo: reducer(state.bar.foo)
foo: fooReducer(state.bar.foo)
}
});
```
const fooAction = payload => reduceFoo(state => ({ ...state, ...payload }));
Using that we can define easily an action, that sets an `x` property in the `foo` object:
```javascript
const setX = x => reduceFoo(state => ({ ...state, x }));
```

@@ -89,3 +93,3 @@

```javascript
const store = new Store(<initialState>)
const store = new Store(initialState)
.addMiddleware(mw1)

@@ -102,3 +106,3 @@ .addMiddleware(mw2, mw3);

const store = new Store(<initialState>).addMiddleware(thunk);
const store = new Store(initialState).addMiddleware(thunk);
```

@@ -135,3 +139,3 @@

const store = new Store(<initialState>)
const store = new Store(initialState)
.addMiddleware(thunk.withExtraArgument({ api, hashHistory }));

@@ -138,0 +142,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