Created
April 25, 2013 00:15
-
-
Save thomasboyt/5456632 to your computer and use it in GitHub Desktop.
theoretical queued saving pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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