# redux-store-observe

> Subscribe to redux store changes

Latest version **1.0.2** (published 2023-10-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install redux-store-observe
pnpm add redux-store-observe
yarn add redux-store-observe
bun add redux-store-observe
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-10-17 |
| First published | 2023-10-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Spicy Sparks |
| Maintainers | spicy_sparks |
| Keywords | redux, store, observe, subscribe, monitor, watch |

## Links

- npm: https://www.npmjs.com/package/redux-store-observe
- npm.io page: https://npm.io/package/redux-store-observe

## 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.2 (latest) — 2023-10-17
- 1.0.1 — 2023-10-17
- 1.0.0 — 2023-10-17

## README

# redux-store-observe
Redux Store observer

## Why?

Redux provides you with a `subscribe()` method so that you can be notified when the state changes. However, it does not let you know what changed or subscribe to partial slices of the store. `redux-store-observe` will let you do that, also with custom equality functions.
`redux-store-observe` completely supports typescript and reflects the types of your state.

## Install

```
npm i --save redux-store-observe
```

## Usage

```js
import store from './store'
import createStoreObserver from 'redux-store-observe'

let observer = createStoreObserver(store)

const unsubscribe1 = observer.observe(
  (state) => state.account.id,
  (value) => console.log(id)
)

const unsubscribe2 = observer.observe(
  (state) => state.account.invoices,
  (value) => console.log(invoices),
  (prevValue, nextValue) => prevValue.length === nextValue.length
)

unsubscribe1()
unsubscribe2()
```

#### Note on Comparisons

By default, `redux-store-observe` uses `===` (strict equal) operator to check for changes. This may not be want you want. Sometimes you may want to do a deep inspection. You can use custom equality functions or use either [deep-equal](https://www.npmjs.com/package/deep-equal) ([substack/node-deep-equal](https://github.com/substack/node-deep-equal)) or [is-equal](https://www.npmjs.com/package/is-equal) ([ljharb/is-equal](https://github.com/ljharb/is-equal)). `is-equal` is better since it supports ES6 types like Maps/Sets.


## License

MIT

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