# stog

> Simple state management

Latest version **0.1.0** (published 2022-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install stog
pnpm add stog
yarn add stog
bun add stog
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-07-19 |
| First published | 2022-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Maksim Yakusik |
| Maintainers | flamstr |
| Keywords | state, model, store, functional, immutable |

## Links

- npm: https://www.npmjs.com/package/stog
- Repository: https://github.com/MaximYakusik/stog
- Homepage: https://github.com/MaximYakusik/stog#readme
- Issues: https://github.com/MaximYakusik/stog/issues
- npm.io page: https://npm.io/package/stog

## 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

- 0.1.0 (latest) — 2022-07-19

## README

# stog

Simple state management

## Install

```
$ yarn add stog
```

## Usage

```js
import { createStore } from 'stog';

// initialize store
const { store, initState, action } = createStore();

const initialState = {
  some: 'value',
  other: 'value',
};

initState(initialState);

const setSome = action((state, some) => {
  return {
    ...state,
    some,
  };
});

const setOther = action((state, other) => {
  return {
    ...state,
    other,
  };
});

// usage

// will call listener each time when calling dispatch for single or multiple action
const listener = state => {
  /* do samting with state */
};
store.subscribe(listener);

// dispatch one action
store.dispatch(setSome('newSomeValue'));

// will return { some: 'newSomeValue', other: 'value' }
store.getState();

// dispatch multiple action
store.dispatch([setSome('newSomeAnotherValue'), setOther('newOtherValue')]);

// will reture { some: 'newSomeAnotherValue', other: 'newOtherValue' }
store.getState();

store.unsubscribe(listener);
```

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