# redux-log-state-diff

> Redux middleware to log actions that change given subsets of state.

Latest version **1.0.3** (published 2020-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-log-state-diff
pnpm add redux-log-state-diff
yarn add redux-log-state-diff
bun add redux-log-state-diff
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-01-22 |
| First published | 2019-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Anders D. Johnson |
| Maintainers | andersdjohnson |
| Keywords | redux, redux-logger, redux-log-diff, redux-log, middleware, state, state, diff |

## Links

- npm: https://www.npmjs.com/package/redux-log-state-diff
- Repository: https://github.com/AndersDJohnson/redux-log-state-diff
- Homepage: https://github.com/AndersDJohnson/redux-log-state-diff#readme
- Issues: https://github.com/AndersDJohnson/redux-log-state-diff/issues
- npm.io page: https://npm.io/package/redux-log-state-diff

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [deep-object-diff](https://npm.io/package/deep-object-diff.md) ^1.1.0

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-01-22
- 1.0.2 — 2019-11-09
- 1.0.1 — 2019-11-03
- 1.0.0 — 2019-11-03

## README

# redux-log-state-diff
> Redux middleware to log actions that change given subsets of state

[![npm](https://img.shields.io/npm/v/redux-log-state-diff)](https://www.npmjs.com/package/redux-log-state-diff)

[![npm add redux-log-state-diff (copy)](https://copyhaste.com/i?t=npm%20add%20redux-log-state-diff)](https://copyhaste.com/c?t=npm%20add%20redux-log-state-diff "npm add redux-log-state-diff (copy)")
[![yarn add redux-log-state-diff (copy)](https://copyhaste.com/i?t=yarn%20add%20redux-log-state-diff)](https://copyhaste.com/c?t=yarn%20add%20redux-log-state-diff "yarn add redux-log-state-diff (copy)")

Ever wonder which action resulted in a change to some part of your Redux state?

Introducing a debugging tool that logs a state diff and action type
when specified parts of the state change,
according to provided state paths or predicate functions.

```
logStateDiff(pathsAndPredicates, options)
```

```js
import logStateDiff from 'redux-log-state-diff'

createStore(
  reducer,
  applyMiddleware(
    logStateDiff([
      'subState.path',
      'otherSubPath.somewhere',
      (prevState, nextState) => prevState.foo !== nextState.foo
    ])
  )
)
```

Now suppose an action `SOME_ACTION_TYPE` is dispatched that updates `state.subState.path`,
then the middleware might log:

```
redux-log-state-diff: action "SOME_ACTION_TYPE", predicate "subState.path" {...a state diff object..}
```

If you want to be able to control which values are logged at runtime, you could wire up a query parameter:

```js
import { logStateDiffParams } from 'redux-log-state-diff'

createStore(
  reducer,
  applyMiddleware(logStateDiffParams())
)
```

Then hit your app with a `__REDUX_LOG_STATE_DIFF__` query parameter with comma-separated state paths:\
[https://localhost:8000/my/path?\_\_REDUX_LOG_STATE_DIFF\_\_=subState.path,otherSubPath.somewhere](https://localhost:8000/my/path?__REDUX_LOG_STATE_DIFF__=subState.path,otherSubPath.somewhere)

and it will act as if you had configured with these state paths:

```js
logStateDiff([
  'subState.path',
  'otherSubPath.somewhere',
])
```

`logStateDiffParams` accepts the same arguments as `logStateDiff` - that is, `pathsAndPredicates` (which will be merged with params-derived ones), and `options`.

---
_Source: https://npm.io/package/redux-log-state-diff · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
