P
P
Pavel2016-03-28 20:13:21
JavaScript
Pavel, 2016-03-28 20:13:21

How to implement a collection collector on the backbone?

Good day!
Here we have a list of users. Each user has a list of options.

// представим, что ниже валидный json
{[
id: 1,
fname: 'Вася',
sname: 'Пупкин',
job: 'Кодер',
statusValid: 1,
statusFilledProfile: 1,
statusOnline: 1,
userActivityWorks: 2,
userActivityComments: 100,
userActivityPosts: 20,
],[
id: 2,
fname: 'Миша',
sname: 'Елкин',
job: 'Опытный кодер',
statusValid: 1,
statusFilledProfile: 0,
statusOnline: 0,
userActivityWorks: 6,
userActivityComments: 70,
userActivityPosts: 26,
]}

Question number 1. Ideological
In theory, the data about status'e and userActivity should be shoved into separate collections, linking them by user's id - it's easier to write backend this way. But whether it is necessary to collect this business on the client? Or is it still immediately collected on the server, and given such a long (as in the example above) json? Accordingly, there will be one backbone-View, not three (user.view, user.status.view, user.activity.view)
Question #2. Practical
If the server is "foreign" and it can send data in pieces: first the list of users, then the list of statuses of received users, then the list of works of each ... etc. how to connect it in backbone?
For each collection according to its model, for each model and collection according to View? Or try to collect a collection of models that connect other models inside themselves? It seems to be possible to do this by setting the user model's status attribute, say, to a reference to the status's model.
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question