How to control live update


#1

Hi,

I want to understand how i can control live update trigger in Scheduler.
Lets say if i am creating event at one side. On another side i should be able to perform some action before the event is pasted on the calendar… or i can stop pasting event…?

Regards


#2

Hi,

Basic version of live update doesn’t provide such functionality.

We are going to update it and expand opportunities so it becomes possible, but I can’t specify the date when it will be implemented.

Currently you can use this custom version
https://files.dhtmlx.com/30d/a493f786df2cc2f6581a8c94e89a7136/live_updates.js
and customize it more as you wish :slight_smile:

Changes from other clients are applied here http://prntscr.com/o1v9uq

You can add some extra entry point to handle something. For example, change the code in the next way:

client.subscribe('/update', function (message) {
     var updateSignal = JSON.parse(message);
     if(scheduler.callEvent("onBeforeLiveUpdate", [updateSignal]) !== false){
        self.applyChanges(updateSignal);
     }
});

Then in your code you can do

scheduler.attachEvent("onBeforeLiveUpdate", function(updateSignal){
    // updateSignal -> {sid: clientId, tid: databaseId, status:"updated|inserted|deleted", data:eventObject}
   // modify updaetSignal to preprocess changes
  // or
   return false;// cancel update
});