Skip to content

Interval function call

This component represents a Supabase function call that is executed at regular intervals.

Props

PropDescription
functionNameThe name of the function to call.
headersOptional headers to include in the function call.
bodyOptional body to include in the function call.
intervalThe interval (in milliseconds) at which the function call should be executed.

Slots

  • default: This slot is rendered when the store is truthy. It receives the following context variables:
VariableDescription
payloadThe data returned by the function call.
errorAny error that occurred during the function call.
functionsThe FunctionsClient instance.
  • loading: This slot is rendered when the store is falsy.

Usage

<script lang="ts">
import { IntervalFunctionCall } from 'supasveltekit';
const interval = 2000;
</script>
<IntervalFunctionCall functionName="get-time" let:payload let:error {interval}>
<div data-testid="interval-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>
</IntervalFunctionCall>