readable
Signature
readable<T>(state: Atom<T> | Selector<T>, store: Store): Readable<T>valdres-svelte Read-only Svelte store subscription
Returns a Svelte store-compatible Readable that you can subscribe to with the $ prefix. Useful when you need a read-only subscription that works with Svelte's store contract.
Usage
<script>
import { atom, selector } from "valdres"
import { readable, getValdresContext } from "valdres-svelte"
const store = getValdresContext()
const nameAtom = atom("Valdres")
const name = readable(nameAtom, store)
</script>
<h1>{$name}</h1>
See also
- watch — reactive object with read/write access
- getValdresContext — get the store from context