Skip to content

svelte

import {
  useStore
} from "exome/svelte";

function useStore

Subscribes to store instance update events and trigger updates to component accordingly.

function useStore<T extends Exome, R = T>(
  store: T,
  selector?: (state: T) => R,
): Subscription;
example.svelte
<script lang="ts">
  import { useStore } from "exome/svelte"
  import { counterStore } from "./counter.store.ts"
 
  const { increment } = counterStore
  const count = useStore(counterStore, s => s.count)
</script>
 
<main>
  <button on:click={increment}>{$count}</button>
</main>