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

1.0.6 • Public • Published

simple-store-svelte

A drop in replacement for svelte/store which uses setters/getters to write/read the store's value.

Now you can do:

// stores.js
import { writable } from 'simple-store-svelte'

const store = writable(null)

store.value = 'Hello world!'

const { value } = store

console.log(value) // 'new value!'

Instead of:

// stores.js
import { writable, get } from 'svelte/store'

const store = writable(null)

store.set('Hello world!')

const value = get(store)

console.log(value) // 'new value!'

Other than the example above, the store is identical as the Svelte one, which means you can use it as you always did.

<!-- App.svelte -->
<script>
  import { store } from './stores.js'

  $store = 'Goodbye world!'
</script>

<div>
  { $store } 
  <!-- null -->
  <!-- Hello world! -->
  <!-- Goodbye world! -->
</div>

Package Sidebar

Install

npm i simple-store-svelte

Weekly Downloads

46

Version

1.0.6

License

MIT

Unpacked Size

11.4 kB

Total Files

6

Last publish

Collaborators

  • thaunknown