Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omer-g/persistent-svelte-store
A generic persistent store according to the Svelte store contract
https://github.com/omer-g/persistent-svelte-store
Last synced: 28 days ago
JSON representation
A generic persistent store according to the Svelte store contract
- Host: GitHub
- URL: https://github.com/omer-g/persistent-svelte-store
- Owner: omer-g
- License: unlicense
- Created: 2022-02-25T19:00:27.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-09T19:11:18.000Z (over 2 years ago)
- Last Synced: 2024-08-03T03:04:56.826Z (4 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 88
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-svelte-stores - persistent-svelte-store
README
# persistent-svelte-store
## Description
A generic persistent writable store, built from scratch in TypeScript according to the Svelte store contract. Store value is stored in `localStorage` as a JSON string, but this is transparent to user. The store is reactive across tabs or windows using the Broadcast Channel API.## Example
Create a store and supply a type
>`stores.ts`
>```typescript
> import { persistentWritable } from "./persistentStore";
> export const store = persistentWritable("storeKey", {});
Use like any writable store
>`App.svelte`
>```typescript
>
> import { store } from "./stores";
> $store = { id: 1 };
> console.log($store.id);
>## Sources
To learn more about Svelte stores see the [Svelte Docs](https://svelte.dev/docs).## Usage
Available for use freely under the [Unlicense License](https://unlicense.org/).