Skip to content

Instantly share code, notes, and snippets.

@elidupuis
Created December 5, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elidupuis/d6b236df6d5f4dfb87b7 to your computer and use it in GitHub Desktop.
Save elidupuis/d6b236df6d5f4dfb87b7 to your computer and use it in GitHub Desktop.
Dynamically reload all hasMany relationships for a model.
/**
* You can use this in a model or afterModel hook...
* see http://emberjs.com/api/data/classes/DS.Model.html#method_eachRelationship
*
* Not really tested or sure if this is a good idea... just had the thought and wanted to record it.
*/
model.eachRelationship(function(name, relationship) {
if (relationship.kind === 'hasMany' && relationship.options.async) {
this.get(name).reload();
}
}, model);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment