I dug around the docs and the forum but I'm not 100% sure what the recommended way is to update my external data source. Currently for updating my events I'm doing this:
const syncData = ({ store, action, records }) => {
if (store.id === 'events') {
const data = records[0].data;
switch (action) {
case 'remove':
updateEvent({
eventID: data.uuid,
});
break;
case 'update':
updateEvent({
eventID: data.uuid,
resourceID: data.resource,
startDate: data.start_date,
arrivalDate: data.arrival_date,
});
break;
}
}
};
This works ok for removing and moving items to others resources. But resizing an event triggers so many updates. I assume those updates happen because all other events might be recalculated too. And I haven't figured out how to determine the action/event which is resized. Or is listening on the store a bad idea and I should use another approach?
on my SchedulerPro Instance.
And this fires a ton of update actions. It seems like all visible events are updated when resizing one single event.
And as I only would like update my remote data for this particular single event I currently can't distinguish which is the update I'm looking for.
That why I wondered if my general approach is the right one.
At least it seems that resizing, adding and deleting events fire only one action for the according event. Dragging an event from one resource to another though triggers and update action on all events that are currently displayed. And that can be a huge amount of requests a once. Just to understand the concept of scheduler pro right: is this way how it's intended how one would handle a drag update for a single event ? That basically all events gets synced with the external datasource?
Could you please provide us test case and steps to reproduce this?
It shouldn't trigger update for all events, but only for related that actually was updated.
SchedulerPro uses Scheduling Engine and yes, change of 1 event will trigger changed for other related events, but not for all.
As I mentioned, possible solution here is using a buffer for event listener and syncing all data with some delay using dataset from schedulerPro.project.changes.
By "related events", we mean the events that are updated/changed in some way because of the main change of the event.
Example:
Event B has a dependency on Event A, if we change the end date of Event A, the start date of Event B could change as well, as it needs to be started after the end of Event A.