Long Polling

Walrus let you setup a long polling script in a very simple way, check the long polling to setup the backend of your long polling first

To subscribe to the long polling in javascript use the following function with the url of your long polling in parameter:

Poling callback

Now to make a specif action you need to register a callback for each table you subscribed to in your backend, if the callback return DOM elements it will automatically be append in all the coresponding DOM hook (explained after)

Walrus.pollingRegister('table1', function (data) {
    var text = '', item;
    for (item in data) {
        text += 'Hello ' + data[item] + '
'; } return text; });

In the previous example, if we get some table1 data, for each row we add the text Hello 'name' and then return it, this text (can also be DOM) will be automatically added to the specified hook

Polling hook

A polling hook is simply an HTML tag where you want some data to be automatically append. For example if we want to display all the new table1 row in an HTML element we just need to add this attribute to it :


Here the div with the data-poll attribute will receive all the content sended by the table1 javascript callback