@atolljs/svelte
v0.1.14
Published
Svelte 5 bindings — observableValue, sharedValue, taskState
Readme
@atolljs/svelte
Svelte 5 bindings for @atolljs/core — shared-memory fields and worker tasks
as rune-backed state. Call the factories during component init (or in a
.svelte.ts module); teardown happens in an $effect cleanup.
Install
npm install @atolljs/core @atolljs/svelteUsage
<script lang="ts">
import { sharedValue, taskState } from '@atolljs/svelte';
import { counterMemory } from './counter.memory';
import { counter } from './counter';
const count = sharedValue(counterMemory, 'count');
const increment = taskState(counter.increment);
</script>
<button onclick={() => increment.run(1)}>
count: {count.value ?? '…'}
</button>API
observableValue(source)— subscribe to anyObservableValuesnapshot as{ value }rune state.sharedValue(memory, key, select?, options?)— bind one shared-memory field as{ value }rune state; optional selector +equals.taskState(task | asyncFn)— bind anAsyncTask(or any async fn) to snapshot getters (data/pending/settled/elapsedMs/error) plusrun/runOncetriggers.
Notes
- Worker-hosted Svelte trees (islands) live in the companion package
@atolljs/svelte-island.
