Skip to content

omer-g/persistent-svelte-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

import { persistentWritable } from "./persistentStore";
export const store = persistentWritable<object>("storeKey", {});

Use like any writable store

App.svelte

<script lang="ts">
  import { store } from "./stores";
  $store = { id: 1 };
  console.log($store.id);
</script>

Sources

To learn more about Svelte stores see the Svelte Docs.

Usage

Available for use freely under the Unlicense License.

About

A generic persistent store according to the Svelte store contract

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published