# watchable-store

> Data model with observer / observable pattern for front-end purpose

Latest version **1.0.4** (published 2016-12-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install watchable-store
pnpm add watchable-store
yarn add watchable-store
bun add watchable-store
```

## 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.4 |
| Published | 2016-12-25 |
| First published | 2016-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | delmotte |

## Links

- npm: https://www.npmjs.com/package/watchable-store
- Repository: https://github.com/delmotte/observable-store
- Homepage: https://github.com/delmotte/observable-store#readme
- Issues: https://github.com/delmotte/observable-store/issues
- npm.io page: https://npm.io/package/watchable-store

## Recent versions

- 1.0.4 (latest) — 2016-12-25
- 1.0.3 — 2016-10-11
- 1.0.2 — 2016-10-11
- 1.0.1 — 2016-10-11
- 1.0.0 — 2016-10-11

## README

# watchable-store

Data model with observer / observable pattern for front-end purpose

## How to use it

```javascript
const WatchableStore = require('watchable-store');
const CounterStore = () => {
  const store = WatchableStore(0 /* Initial Data */);
  store.increment = function () {
    // modifing data here notify all watchers
    this.data = this.data + 1;
  };
  store.decrement = function () {
    this.data = this.data + 1;
  };
  return store;
};

// subscribe to data change
const subcription = CounterStore.watch(counter => console.log('new value : ' + counter));

CounterStore.increment();
CounterStore.increment();
CounterStore.decrement();

// unsubscribe when you're done with it
CounterStore.unwatch(subscription);
```

DeepFreeze is used by default in order to manipulate immutable data, to disable it just initialize your store like this :
```javascript
  const store = WatchableStore(0, {disableDeepFreeze: true});
```

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