# tiamut

> Simple state management (React optional)

Latest version **1.2.2** (published 2022-09-13) · MIT license · 0 weekly downloads

## Install

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

## 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.2.2 |
| Published | 2022-09-13 |
| First published | 2022-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | An Duong |
| Maintainers | ahdng |
| Keywords | react, state, manager, management, redux, store, zustand, recoil |

## Links

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

## Dependencies (1)

- [use-sync-external-store](https://npm.io/package/use-sync-external-store.md) ^1.2.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.2.2 (latest) — 2022-09-13
- 1.1.3-beta.2 (beta) — 2022-09-06
- 1.2.1 — 2022-09-12
- 1.2.0 — 2022-09-11
- 1.1.5 — 2022-09-10
- 1.1.4 — 2022-09-06
- 1.1.3 — 2022-09-06
- 1.1.3-beta.1 — 2022-09-06
- 1.1.2 — 2022-09-06
- 1.1.1 — 2022-09-06
- 1.1.0 — 2022-09-06
- 1.0.8 — 2022-09-05
- 1.0.7 — 2022-09-05
- 1.0.6 — 2022-09-05
- 1.0.5 — 2022-09-05
- … 5 more at https://npm.io/package/tiamut/versions

## README

# Tiamut

Simple state management (React optional)

## Example

https://githubbox.com/anduong96/Tiamut/tree/main/example

## Installation

```bash
npm i --save tiamut
```

# Usage with React

## Basic

```tsx
import { createStoreHook, createStore } from 'tiamut';

const store = createStoreHook(
  createStore({
    initialState: {
      value: 1,
    },
    actions: {
      addOne(state) {
        return {
          ...state,
          value: value + 1,
        };
      },
    },
  }),
);

const MyApp = () => {
  const value = store.useSelect((state) => state.value);

  function addOne() {
    // Call this from anywhere
    // Even outside of component
    store.actions.addOne();
  }

  return (
    <div>
      <div>{value}</div>
      <button onClick={addOne}>Add One</button>
    </div>
  );
};
```

## With slices

```tsx
import { createStore, createCombinedStoreHook } from "tiamut";

const foo = createStore({
  initialState: {
    value: 1,
  },
});

const bar = createStore({
  initialState: {
    value: 2,
  },
  actions: {
    addOne(state) {
      return {
        ...state,
        value: state.value + 1
      }
    }
  }
});

const store = createCombinedStoresHook({
  foo,
  bar,
});

const MyApp = () => {
  const value = store.useSelect((state) => state.foo.value);

  function handleAction() {
    store.actions.bar.addOne();
    // or
    // bar.actions.addOne();
  }

  return (
    <div>
      <div>{value}</div>
      <button onClick={handleAction}>Add One</button>
    </div>;
  )
};
```

## Enhancers

- [With Shallow](./docs/enhancers/with.shallow.md)
- [With Immer](./docs/enhancers/with.immer.md)

## Recipes

- [Persisting](./docs/recipes/persist.md)
- [Debug Changes](./docs/recipes/log.changes.md)

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