Here is my pseudocode:
-
App.DS.RESTAdapter
-
App.MyData {id, description, hobby, skills}
-
IndexRoute: model : return store.find(‘mydata’); This however returns only {mydata: [{id1, description1}, {id2, description2}]}. Notice - it does not have hobby and skills returned.
-
components/mydata-list #each a_mydata {{#mydata-detail action=showDetail a_mydata store}} {{a_mydata.hobby }} {{ a_mydata.skills}} {{/mydata-detail}}
-
component/mydata-detail {{yield}}
-
mydataDetailComponent model : undefined, actions : { showDetail : function(a_mydata, store) { a_mydata = store.find(‘mydata’, a_mydata.id); // this results in rest call → /mydata/:id and gets complete record including hobby and skills } }
My interpretation: Since a_mydata is available in both mydata-list and mydata-detail, and is updated in a_mydata, the {{yield}} in mydata-detail is getting the updated value! i.e. it is showing hobby and skills that were not available in mydata-list. I am thinking this is because Javascript object - a_mydata - is by reference.
Question: Is this a valid design + future compliant design pattern?
Thanks, Sandeep