Skip to main content

getState

Returns a non-reactive snapshot of the calendar composable state - the active date, view, visible range, events, filters, and currently selected event. Use it for one-off reads. For reactive subscriptions, use getReactiveState.

Usage

getState(): State;

type State = {
currentDate: Date;
currentView: string;
rangeLabel: string;
visibleDateRange: { start: Date; end: Date };
events: EventsStore;
viewData: any;
filters: Map<string, (obj: any) => boolean>;
editorData: CalendarEvent | null;
};

State fields:

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

Example

<script setup lang="ts">
import { ref } from "vue";
import { Calendar } from "@wx/vue-calendar";
import type { CalendarInstanceApi } from "@wx/vue-calendar";

const api = ref<CalendarInstanceApi | null>(null);

function logState() {
const state = api.value.getState();
console.log(state.currentView, state.rangeLabel);
}
</script>

<template>
<Calendar :events="events" ref="api" />
<button :onclick="logState">Log state</button>
</template>
  • getReactiveState — same fields as reactive refs.
  • getStores — direct store access for advanced integrations.
  • getEvents — list events filtered by date range.
  • exec — dispatch actions that change this state.