Skip to main content

getReactiveState

Returns reactive Svelte stores for each state field. Subscribe to a store to re-render when its value changes - useful inside custom toolbar items and other child components.

Usage

getReactiveState(): TState<State>;

State fields:

FieldTypeDescription
currentDateDatePivot date that determines the visible range
currentViewstringActive view id
rangeLabelstringDisplay label for the current date range
visibleDateRange{ start: Date; end: Date }Start/end of the visible range
eventsEventsStoreInternal event storage
viewDataanyView-model render data for the active view
filtersMap<string, (obj: any) => boolean>Active filter predicates keyed by tag
editorDataCalendarEvent | nullCurrently selected event, or null

Example

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

let api;

function onInit(obj) {
api = obj;
const { rangeLabel } = api.getReactiveState();
rangeLabel.subscribe(label => console.log("range:", label));
}
</script>

<Calendar {events} {date} init={onInit} />
  • getState — non-reactive snapshot of the same fields.
  • getStores — direct access to the underlying store instance.
  • exec — dispatch actions that mutate state.
  • Navigation bar — typical consumer of reactive state inside custom toolbar items.