I'm building a real-time feed application using Backbone.js, node.js and socket.io.
My Feed
is a collection of Update
models. Displaying these, overriding Backbone.sync
for integration with socket.io
works fine.
The complication comes in that each Update
has a set of comments associated with it. When I show each Update
in the Feed
view, I want to show a summary of the associated comments (number of comments and a single 'most poular' comment), and also have the ability to click through to a different view to display each Update
on its own with a paginated list of comments with further data.
I'm using backbone-relational
to model the relationship between the Update
model and Comment
model, as follows:
Feed (collection) -> Update (model) -(has many)-> Comment (model)
I've been following this backbone-relational
tutorial, but it seems to assume that I'd want to have all related data in memory at once in my Feed
view, which I don't as there are potentially thousands of comments updating in real-time:
http://antoviaque.org/docs/tutorials/backbone-relational-tutorial/
My questions are:
- How can I bring in summary data for comments to each
Update
in myFeed
view without loading all comment data, and also maintain the ability to show paginated full data in myUpdate
view? - I'm using
backbone.layoutmanager
for rendering my views. How best should I break my views up to accomplish the above?