Reputation: 4003
If I have a deeply-nested model graph, coming from the server (a lot of children objects, some of which arrays). Is it a good practice to turn each of the children of the object, into Models and Collections respective, when I turn the object into a Model? This will be handy because it will reduce the confusion of what should be called how. For example, it is much clearer to have something like that:
myModel.get("child1").get("collection1").get(0);
instead of:
myModel.get("child1").collection1[0];
On another side, it might turn into a performance hell if we are trying to convert these at runtime, especially if the object graph is really deep.
What is the best practice there?
Upvotes: 2
Views: 266
Reputation: 7344
You should use Backbone.relational to take care of it for you.
Upvotes: 3