2.0.1 • Published 8 months ago

asphelt.io v2.0.1

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Thanks for using Asphelt, a component and utility library for SvelteKit

About Custom Stores:

General idea

Provide svelte stores that work just like svelte stores, but are backed by localStorage or sessionStorage, to persist data between sessions or avoid losing data on an eventual refresh.

Importing

// stores/index.ts
import { localable } from '$lib/stores/localable';
import { sessionable } from '$lib/stores/sessionable';

const myStore = localable('myStore', {initialValue: 'initialValue'}); // persisted in localStorage
const myOtherStore = sessionable('myOtherStore', {initialValue: 'initialValue'}); // persisted in sessionStorage

Using

// ○○.svelte
<script>
    import { myStore, myOtherStore } from '$lib/stores';

    $myStore.valueToStore = 'newValue';
    $myOtherStore.valueToStore = 'newValue';

</script>

Warnings

The stores do not discriminate between users. Preferences saved locally will be shared between users. Any user-specific data storage has to be implemented manually.

Remember not to store any sensitive data in localStorage or sessionStorage!

2.0.1

8 months ago

2.0.0

8 months ago

1.1.0

8 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago