noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.
https://noveogroup.github.io/backbone.iobind/
582 stars 65 forks source link

"Streaming" or partial collections #39

Closed mauron85 closed 11 years ago

mauron85 commented 11 years ago

I like this library, But I'm missing feature I call partial processing (or streaming collections)

The main benefit of websockets is that server could send collection data that spans into multiple responses. It allows partial processing.

Wouldn't it be nice if this library supports collections streaming (or partial collections)? So server can send chunks of data (flagged with partial: true) so client knows, that more data is comming, but also can process (render) partial results.

Currently this is not possible on client (backbone) side.

mahnunchik commented 11 years ago

Backbone.iobind uses socket.io for data delivery. Socket.io uses not only websockets also flashsockets, jsonp-polling etc

Your question can be solved by following code on the client:

initialize: function () {
  this.ioBind('serverUpdate', this.serverUpdate, this);
}
serverUpdate: function (data) {
  this.add(data);
}

And your server may send chunked data.

mauron85 commented 11 years ago

Thank you. It works!