Search code examples
dojocometd

cometd hello world example with dojo


I'm trying to follow the basic cometd example here: http://dojotoolkit.org/reference-guide/1.7/dojox/cometd.html

It's using the old module loader so I tried the equivalent as follows:

require(["dojo/ready","dojo/io/script","dojox/cometd","dojox/cometd/callbackPollTransport"], function(ready, dontcare, cometd) {
    ready(function(){   
        cometd.init('http://localhost:8080/MyCometD/cometd');
        comted.subscribe("/test", function(msg){
            console.debug(msg);
        });
    });
});

This doesn't work and I think it has to do with loading modules - there is some sort of silent error as the code within the ready function does not execute at all. What I found is that when the "dojox/cometd" require statement is present, the code within the ready function does not execute.

Running example: http://jsfiddle.net/Q9W8f/2/

Example with dojox/comted removed: http://jsfiddle.net/mMs2h/4/

I haven't worked with the new module loader that much so I bet I just have some simple misconception.

Help!


Solution

  • It seems like youre correct and that there is a 'wait-loop' for a module requirement that never gets loaded. This may be any of the requirements inside dojox.cometd and you'd need to rewrite the codebase for a fix.

    I have had similar issue with the RollingListPane, also in dojox repository - and the developers are saying 'we are 100% AMD compliant with 1.7' however the X in dojox is short for experimental. The developement of dojox modules is not done by the core djtk team and there are still glitches..

    Try for starters to avoid using CDN which has performed a >>built macro on every single module. This tends to fail at times whilst using AMD. Instead download the tarball and use a local copy - Not compressed (dojo-release-1.7.2-src)