Serpenta Developer Handbook 1.0 Help

Alerting over events

Using the Tauri event listeners, one can listen for specific events on an error or warning channel and trigger alerts using the already integrated Skeleton Toast.

Basic setup

(not included in Serpenta)

<script lang="ts"> import { getToastStore } from '@skeletonlabs/skeleton'; import { listen } from "@tauri-apps/api/event"; const toastStore = getToastStore(); const unlisten = listen('error_channel', event => { toastStore.trigger({ message: event.payload.message, background: 'variant-filled-error', }) }); // free memory onDestroy(() => unlisten); </script>

It is up to the backend to implement the trigger that will send a message to this event.

Last modified: 29 August 2024