Nondeterministic Programming Methodology

    svelte-local-storage-store
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.6 • Public • Published

    npm version license codecov

    svelte-local-storage-store

    A store that adds pub/sub to local storage. Supports changes across multiple tabs.

    Installation

    npm install svelte-local-storage-store

    Usage

    Define the store:

    import { writable } from 'svelte-local-storage-store'
    
    // First param `preferences` is the local storage key.
    // Second param is the initial value.
    export const preferences = writable('preferences', {
      theme: 'dark',
      pane: '50%',
      ...
    })

    Then when you want to use the store:

    import { get } from 'svelte/store'
    import { preferences } from './stores'
    
    preferences.subscribe(...) // subscribe to changes
    preferences.update(...) // update value
    preferences.set(...) // set value
    get(preferences) // read value
    $preferences // read value with automatic subscription

    License

    MIT

    Keywords

    Install

    npm i svelte-local-storage-store

    DownloadsWeekly Downloads

    1,523

    Version

    0.2.6

    License

    MIT

    Unpacked Size

    11 kB

    Total Files

    7

    Last publish

    Collaborators

    • joshnuss