Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kusstar/signals-persist
A library for persisting state of a [signal](https://github.com/preactjs/signals).
https://github.com/kusstar/signals-persist
persist preact react signals state-management storage
Last synced: 7 days ago
JSON representation
A library for persisting state of a [signal](https://github.com/preactjs/signals).
- Host: GitHub
- URL: https://github.com/kusstar/signals-persist
- Owner: KusStar
- License: mit
- Created: 2023-04-20T08:09:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-20T08:10:06.000Z (over 1 year ago)
- Last Synced: 2024-12-18T06:23:30.035Z (9 days ago)
- Topics: persist, preact, react, signals, state-management, storage
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# signals-persist
A library for persisting state of a [signal](https://github.com/preactjs/signals).
## Installation
```bash
npm install signals-persist
yarn add signals-persist
pnpm add signals-persist
```## Usage
### React
Install the `@preact/signals-react` package.
```bash
npm i @preact/signals-react
yarn add @preact/signals-react
pnpm add @preact/signals-react
``````jsx
import { signal } from '@preact/signals-react'import { persist } from 'signals-persist'
const count = persist(signal(0), 'count')
const App = () => {
return (
{count.value}
count.value++}
>
count++
)
}export default App;
```### Preact
Install the `@preact/signals` package.
```bash
npm i @preact/signals
yarn add @preact/signals
pnpm add @preact/signals
``````jsx
import { signal } from '@preact/signals';
import { persist } from 'signals-persist'const count = persist(signal(0), 'count')
const App = () => {
return (
{count.value}
count.value++}
>
count++
)
}export default App;
```
## License
[MIT](LICENSE)