S
S
sdevalex2011-11-16 14:50:32
JavaScript
sdevalex, 2011-11-16 14:50:32

JS Stack of events on the page

I have a page on which a bunch of blocks should be updated almost in real time (I saw a photo > after 20 seconds it changes to > I saw a photo and left a comment > after 2 hours > I left the site).

The easiest way is to make separate requests for each part of the page, but this is expensive. There was an idea to make a request every 5 seconds to query the server about events and set a Callback for certain data:

var handlerUrl = '/data/events';
var listen = new Listen(handlerUrl, 5);

listen.on('tape', 'create', function(item){
     $('...').append(item.content);
});

listen.on('tape', 'update', function(id, item){
     $(id).html(item.content);
});

listen.on('tape', 'remove', function(id, item){
     $(id).remove();
});


Is there something ready for this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zolotyh, 2011-12-13
@zolotyh

You can use Backbone.js. To change the model, hang up events that will redraw the page. And download the model from the server at a specified frequency.

D
Dmitry, 2011-12-14
@Neir0

Knockout + mapper plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question