# writable-store

> Tiny tiny state management package inspired by Svelte stores.

Latest version **1.1.0** (published 2020-07-18) · MIT license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2020-07-18 |
| First published | 2020-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | anthonypenna |
| Maintainers | anthonypenna |
| Keywords | svelte, writable, store, state, management |

## Links

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

## 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.1.0 (latest) — 2020-07-18
- 1.0.0 — 2020-07-17

## README

# Writable Store
Tiny tiny state management package inspired by Svelte stores.

## Installation
```bash
$ npm i writable-store
```

## Setup
Import `writable` and create a writable store with an initial state:
```js
import { writable } from 'writable-store'

export const todoStore = writable([])
```

Import the store inside your component and subscribe to receive updated values:
```js
import { todoStore } from './stores'

const $todos = todoStore.subscribe(todos => /* Do something... */)
```

You can use the value received after subscription to update component props, state etc...

To update the store with a new value:
```js
todoStore.set(todos => /* New value... */)
```

To retreive the current store value:
```js
todoStore.get() 
```

Remember to unsubscribe during cleanup / unmounting:
```js
$todos.unsubscribe()
```

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