This article refers to the legacy implementation of the Live Updates mode for DHTMLX Scheduler. See the details on the current version here.
Live Update is a mode that provides synchronous data updates in real time.
When one user makes a change, it becomes visible to all others immediately.
The mode uses the Faye
socket library to make the process as fast and flexible as possible and doesn't require page refreshes (it updates only the component to which it's applied).
In this article, we will give you a step-by-step tutorial to quickly dive into the topic.
Live updates are achieved by broadcasting changes made by one connected client to all other connected clients. This is done by utilizing a WebSocket connection for two-way message exchange between connected clients and the backend.
In this version of the Live Updates module, it is implemented by extending the DataProcessor
module to use the Faye
library client, along with an additional backend application that dispatches messages between clients.
The solution consists of three parts:
DataProcessor
module.When a user makes changes to the data:
To start this tutorial, you must have a fully functional dhtmlxScheduler application integrated with server-side logic - one that loads data from a database and saves changes back. (See details here.)
A basic example of such an application might look like this:
<script>
function init() {
scheduler.init('scheduler_here', new Date(2025,5,24), "week");
scheduler.load("api/scheduler");
const dp = scheduler.createDataProcessor({
url: "/events",
mode: "REST"
});
}
</script>
This implementation of Live Updates is deprecated and is not included in the main package.
To work with the Live Update mode, include two additional files in the frontend app:
<script src="./lib/dhtmlxscheduler/live_updates.js"></script>
<script src="http://localhost:8008/client.js"></script>
In the code sample above, we connect directly to the WebSocket app. Usually, you'll want to route this URL through your main app to avoid exposing the address and port of the secondary app. This can be done by using a reverse proxy.
Proxying requests through the main app (Node.js):
const httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({});
module.exports = function(app){
app.all("/liveUpdates*", function(req, res) {
proxy.web(req, res, {target: "http://localhost:8008"});
});
}
Front-End:
<script src="./lib/dhtmlxscheduler/live_updates.js"></script>
<script src="/liveUpdates/client.js"></script>
The mode is enabled by calling the live_updates() method on the DataProcessor
instance. For this to work, you must have the DataProcessor
initialized first. As a parameter, the method takes the URL of the WebSocket entry point.
const dp = scheduler.createDataProcessor({
url: "/events",
mode: "REST"
});
dp.live_updates("/liveUpdates");
You can download a complete demo application here.
Back to top