Skip to main content

getEvent

Looks up an event in the calendar store by its id. Returns undefined when no event matches.

Usage

getEvent(id: string | number): CalendarEvent | undefined;
ParameterTypeDescription
idstring | numberEvent id to look up

Example

<script>
import { Calendar } from "@svar-ui/svelte-calendar";

let api;

function logEvent() {
const event = api.getEvent(42);
console.log(event);
}
</script>

<Calendar bind:this={api} {events} />

Generated recurring-instance IDs — the encodeId() form such as "42###2026-03-09" returned by getEvents(start, end) — do not resolve here; getEvent returns undefined for them. Look the instance up in a bounded getEvents result instead.

  • getEvents — list events in a date range.
  • getState — full state snapshot including selected event.
  • events — the source array getEvent looks up against.