Premium support for our pure JavaScript UI components


Post by mightym »

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?

Thanks a lot!


Post by alex.l »

Hi,

Or is listening on the store a bad idea and I should use another approach?

What exactly are you listening to here? Is syncData a listener of some event? Which event?
To catch data change you can listen to store's events or project's events.
As example https://bryntum.com/products/schedulerpro/docs/api/SchedulerPro/model/ProjectModel#event-change
If you have too much events triggered and want to save all in once, you can specify buffer and call hander on timeout to catch all
https://bryntum.com/products/schedulerpro/docs/api/Core/mixin/Events#function-on
https://bryntum.com/products/schedulerpro/docs/api/Core/mixin/Events#typedef-BryntumListenerConfig
See buffer option.

All the best,
Alex


Post by mightym »

I'm using

onDataChange={syncData}

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.


Post by mightym »

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?


Post by alex.l »

Hi,

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.

All the best,
Alex


Post by mightym »

What do you mean by "related events" ? Events that have the same resource, events that are dependent on others, events that overlap ...?


Post by marcio »

Hey,

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.

Best regards,
Márcio


Post Reply