dimanche 6 mars 2016

Ember Docs - Readonly Nested Data

I have been reading the Ember documentation for v2.4, and I came across a part that I don't understand:

"Some models may have properties that are deeply nested objects of readonly data. The naïve solution would be to define models for each nested object and use hasMany and belongsTo to recreate the nested relationship. However, since readonly data will never need to be updated and saved this often results in the creation of a great deal of code for very little benefit. An alternate approach is to define these relationships using an attribute with no transform (DS.attr()). This makes it easy to access readonly values in computed properties and templates without the overhead of defining extraneous models."

In my use case, I will only be displaying data, it will never be saved back to the server. Every example I have found for nested data, shows setting up separate models for each level of nesting, then setting up the relationships, as referred to as the "naive solution". So what would be the correct way to go about this? Can anyone please expand on this for me? Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire