Recurring eventsScheduler
Repeat events with RFC 5545 rules, skip dates with exdates, and decide whether a drag, resize or delete changes one occurrence or the whole series.
Give an event an RFC 5545 rule in rrule and it repeats on the timeline: a daily vehicle check, weekly planned maintenance, a monthly inspection. The rules are read by the same engine as the Event Calendar, so a series means the same thing in both products.
A recurring event#
scheduler.addEvent({
id: 'ppm-hillside',
resourceId: 'maya',
title: 'Planned maintenance: Hillside Care Home boilers',
start: '2026-11-02T08:00',
end: '2026-11-02T10:00',
rrule: 'FREQ=WEEKLY;BYDAY=MO',
exdates: ['2026-12-28T08:00'],
});startandendare the first occurrence; every occurrence has the same duration.rruleis written with or without theRRULE:prefix.FREQ=DAILY|WEEKLY|MONTHLY|YEARLY,INTERVAL,COUNT,UNTIL,BYDAY(including1MOand-1FR),BYMONTHDAY,BYMONTH,BYSETPOSandWKSTare supported. Unsupported parts are ignored with one console warning; an invalid rule shows the event once, also with a warning.exdatesskips occurrences. A date-time skips the occurrence that starts then; a plain date ('2026-12-28') skips every occurrence on that day.- Occurrences keep their wall-clock time in the scheduler's
timeZoneacross daylight-saving changes. - Occurrences are generated only for the visible range, up to 5,000 per series, so a rule without an end costs nothing outside the view.
Occurrence ids#
Each occurrence is rendered as an event whose id is the series id, @, and the occurrence's local start: 'ppm-hillside@2026-11-23T08:00:00'. It carries recurringEventId (the series id) and recurrenceId ('2026-11-23T08:00:00').
getEvents()returns the series once, as you stored it.getEventById(occurrenceId)andgetEventsInRange()also return occurrences.updateEvent(occurrenceId, patch)andremoveEvent(occurrenceId)change a single occurrence, the same way a drag or delete does.
This occurrence or the whole series#
When a user drags, resizes or deletes an occurrence, eventDrop, eventResize and eventRemove fire before the change is applied, with occurrence and a mutable scope that starts as 'this':
scope |
Drag or resize | Delete |
|---|---|---|
'this' |
Adds the occurrence to the series' exdates and adds a single event with the occurrence id, recurringEventId and recurrenceId at the new time |
Adds the occurrence to exdates |
'all' |
Moves or resizes the whole series by the same amount; weekday rules (BYDAY) shift with it |
Removes the series |
Set scope synchronously inside the listener:
const wholeSeries = document.querySelector<HTMLInputElement>('#whole-series')!;
scheduler.on('eventDrop', (change) => {
if (change.occurrence) change.scope = wholeSeries.checked ? 'all' : 'this';
});
scheduler.on('eventRemove', (change) => {
if (change.occurrence) change.scope = confirm('Delete every visit in this series?') ? 'all' : 'this';
});Saving recurring changes#
A change to one occurrence touches two records: the series (a new exdates entry) and the detached single event. Persist both. The historyChange event lists every record a user action changed, with before and after, which makes it the simplest place to save:
scheduler.on('historyChange', ({ action, changes }) => {
if (action === 'clear') return;
for (const { id, before, after } of changes) {
if (after === null) void jobs.remove(id);
else if (before === null) void jobs.create(after);
else void jobs.update(id, after);
}
});historyChange fires unless history is turned off with undoRedo: false; see Undo and redo.
Related#
- Recurring jobs recipe
- Calendar recurrence for the rule syntax in detail
- Drag, drop, resize and create