Skip to main content

api.getReactiveState()

Description

Gets an object with the reactive properties of the Event Calendar StateStore

Usage

api.getReactiveState(): object;

Returns

The method returns an object with the following properties:

{
bounds: object,
calendars: object,
colors: object,
config: object,
date: object,
datepicker: object,
dateRange: object,
edit: object,
editorShape: object,
events: object,
mode: object,
popupInfo: object,
selected: object,
sidebar: object,
viewData: object,
viewModel: object
}

Example

// create Event Calendar
const calendar = new eventCalendar.EventCalendar("#root", {
// configuration properties
});

// get reactive state
const state = calendar.api.getReactiveState();

// subscribe on the calendars changes and output the calendars data
state.calendars.subscribe((data) => {
console.log(data);
});

// subscribe on the events changes and output the events data
state.events.subscribe((data) => {
console.log(data);
});

// subscribe on the event selection and output the data of the selected event
state.selected.subscribe((data) => {
console.log(data);
// other actions
});

// subscribe on the date changes and output the selected date
state.date.subscribe((date) => {
console.log(date);
});

// subscribe on the modes changes and output the selected mode
state.mode.subscribe((mode) => {
console.log(mode);
});

// set new mode
state.mode.set("day");

// update mode
state.mode.update((mode) => {
if(mode === "day"){
return "week";
}
});