Skip to content

Delayed function call

A Svelte component that allows for delayed function calls using Supabase Functions.

Props

ParameterTypeDescription
functionNamestringThe name of the Supabase Function to call.
headersanyOptional headers to include in the function call.
bodyanyOptional body to include in the function call.
delaynumberThe delay in milliseconds before making the call.

Slots

  • default: The default slot that receives the payload, error, and functions client.
ParameterTypeDescription
payloadany | nullThe payload returned by the function call.
errorError | nullAny error that occurred during the function call.
functionsFunctionsClientThe Supabase Functions client.
  • loading: The slot to show while the function call is being delayed.

Usage

<script lang="ts">
import { DelayedFunctionCall } from 'supasveltekit';
const delay = 2000;
</script>
<DelayedFunctionCall functionName="get-time" let:payload let:error {delay}>
<div data-testid="delayed-function-call">
{#if payload}
<h1>The time is {payload.time}</h1>
{:else if error}
<h1>There was an error: {JSON.stringify(error)}</h1>
{:else}
<h1>Loading...</h1>
{/if}
</div>
</DelayedFunctionCall>