Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created April 25, 2013 00:15
Show Gist options
  • Save thomasboyt/5456632 to your computer and use it in GitHub Desktop.
Save thomasboyt/5456632 to your computer and use it in GitHub Desktop.
theoretical queued saving pattern
var MyModel = DS.Model.extend({
// ...
saveQueued: false,
save: function() {
Ember.run.sync(); //may actually need to be a Ember.run.once(function() {...}) wrapper
if (this.get("stateManager.currentState.name" == "inFlight")) {
if (!this.get("saveQueued")) {
this.set("saveQueued", true);
this.one("didSave", function() {
Ember.run.sync();
this.set("saveQueued", false);
this.store.commit();
})
}
}
else {
this.store.commit();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment