Integration of Ajax and Comet Libraries

by Martin TylerMarch 3rd, 2008

Most Comet client libraries work on the principle of allowing you to attach a callback to a subscription of some kind. This may give you a lot of flexibility, but can lead to a lot of the same things being implemented over and over on top of this when writing an actual application.

In a previous article of mine on the performance of grids for streaming data, I implemented examples using both Dojo and Yahoo UI grids with streaming data. The grids were hooked up to Liberator using the JavaScript library which comes with Liberator. This experience led me to think that the current crop of Ajax libraries are not really designed to handle real time data. Yes, it was fairly easy to get the data into the grids, but what appeared to be a nice MVC/Observer architecture actually required you to tell the grid to set a cell or row rather than just updating a model. To use YUI terms, DataTable should be observing DataStore, which would allow a real time implementation of a DataStore.

This is where I think some work is needed: in the integration of Comet libraries with Ajax libraries. I know that Dojo includes both, and I haven’t looked closely at it for a while, but I suspect that although they are part of the same library there isn’t all that much integration. I am not saying that all Ajax libraries should be tightly coupled to a Comet library, and that would probably be a bad idea, but they could certainly think more about real time data rather than true Ajax style ‘reload me a chunk of XML’.

This all leads to ease of use of real time data in Ajax/Comet applications. An early example of this can be seen in Liberator with the RTML Demos. If you look at the RTML Basic Example you can see that there is no JavaScript and no callback to implement, just markup and a single script tag to load the library.

However, in today’s world where the GUI of an Ajax application is often built up from code rather than using simple HTML, the example above is not that useful. This doesn’t mean the same ease of use cannot be extended to Ajax libraries to pull in real time data.

If you want a tab header to contain some real time text, it could be created as a RealTimeTextNode, with all the necessary information to set up a subscription and callback—job done. This could then be used anywhere you like within your GUI, as opposed to having to setup the callback yourself to change the text of the tab and littering the code with anonymous functions. The implementation of a RealTimeTextNode could allow for different Comet libraries fairly easily.

These are just a couple of examples of where streaming data could be made a lot easier for the programmer.

2 Responses to “Integration of Ajax and Comet Libraries”

  1. Comet Daily » Blog Archive » Real-time Widgets with the Dojo Toolkit Says:

    [...] Martin Tyler’s recent post on the Integration of Ajax and Comet Libraries, he comments that the widget systems in YUI and the Dojo Toolkit are not yet particularly suited [...]

  2. Jashua Newway Says:

    if you use .NET, you dont have to integrate or worry about ajax. There is a free library named PokeIn. It handles all these things.

Copyright 2015 Comet Daily, LLC. All Rights Reserved