Our pure JavaScript Scheduler component


Post by SIM-LTD »

Is there any way to know how many occurrences will be created before the user valid the event?

Indeed, we need to create each occurrence in the database (for analysis purpose) then we would like to secure the number of occurrences that could potentially be created (avoiding a smart person to fill the database with millions of records).

Post by arcady »

First of all, occurrences in terms of the Scheduler always mean visible only occurrences. The Scheduler creates them on the fly for visible timespan only.
Ultimately the number of a repeating event instances can be infinite (unless user provides some stop condition (number of times to repeat or stop date)).

If you want to know what number of visible occurrences is about to get added you can listen to event store https://www.bryntum.com/docs/scheduler/#Scheduler/data/EventStore#event-beforeAdd event:
eventStore.on("beforeAdd", ({ records }) => {
    // if the 1st record is an occurrence we are in the middle of occurrences generating
    if (records[0].isOccurrence) {
        console.log(`Number of occurrences ${records.length}`)
    }
})
But that will return bulk of occurrences for multiple events.

Post Reply