@reffect/localstore
Version:
localStorage middleware for Reffect
31 lines (19 loc) • 1.31 kB
Markdown
<div align="center">
[](https://github.com/acacode/reffect)
[](https://www.npmjs.com/package/@reffect/localstore)
[](https://bundlephobia.com/result?p=@reffect/localstore)
[](https://github.com/acacode/reffect)
<div align="left">
Reffect — is a declarative and reactive multi-store state manager for JavaScript/TypeScript applications inspired by [Reatom](https://github.com/artalar/reatom) and [Effector](https://github.com/zerobias/effector)
# @reffect/localstore
Store middleware for [`Reffect`](https://github.com/acacode/reffect)
## How to use
```ts
import { store, effect } from "@reffect/core";
import { localstore } from "@reffect/localstore";
const keyboards = store({ list: [] }, "keyboards-store", [localstore]);
const updateKeyboardsList = effect(keyboards, "list");
updateKeyboardsList([{ foo: "2" }]);
// ...
// localStorage.getItem("@reffect/store/keyboards-store") -> "{"list":[{"foo":"2"}]}"
```