@daltonr/notifywrite-svelte
v0.3.0
Published
Svelte adapter for @daltonr/notifywrite
Maintainers
Readme
@daltonr/notifywrite-svelte
Svelte adapter for @daltonr/notifywrite — the headless notification engine as a Readable store, auto-managed by the store's start/stop contract (no onDestroy needed).
npm install @daltonr/notifywrite @daltonr/notifywrite-svelte<script>
import { NotificationEngine } from "@daltonr/notifywrite";
import { provideNotifications, useNotifications } from "@daltonr/notifywrite-svelte";
const engine = new NotificationEngine({ order: "newest-first" });
provideNotifications(engine); // descendants call useNotificationsContext()
const { notifications, add, dismiss } = useNotifications(engine);
</script>
{#each $notifications as n (n.id)}
<div on:click={() => dismiss(n.id)}>{n.message}</div>
{/each}See the project README for the full engine API.
MIT © Richard Dalton
