@dyadpy/svelte
v0.1.1-alpha.0
Published
Svelte store bindings (query, mutation, subscription) for Dyadpy-generated clients.
Maintainers
Readme
@dyadpy/svelte
Svelte 5 store bindings for Dyadpy-generated
clients. Three factory functions on top of the typed api:
| Store | What it does |
| -------------- | -------------------------------------------------------------------------- |
| query | Fires a unary call when subscribed; tracks status/data/error. |
| mutation | Returns a mutate(args) you call imperatively. |
| subscription | Subscribes to a stream[T] endpoint; events forwarded to an onEvent cb. |
Install
pnpm add @dyadpy/svelte @dyadpy/ts svelteUse
<script lang="ts">
import { createDyadpyStores } from "@dyadpy/svelte";
import { api } from "$lib/dyadpy/client";
const stores = createDyadpyStores(api);
const issue = stores.query("getIssue", { issueId: 1 });
</script>
{#if $issue.status === "loading"}
Loading…
{:else if $issue.status === "success"}
{$issue.data.title}
{:else if $issue.status === "error"}
Failed: {$issue.error.kind}
{/if}For a @raises(...) route the error slot is the typed discriminated union
from Python; for a route without @raises, it's a thrown Error.
License
MIT
