Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 Update #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*
* MIT licensed.
*/
(function() {

// based on Backbone.js' inherits
var ctor = function(){};
Expand Down Expand Up @@ -52,17 +51,19 @@ Undo.Stack = function() {
};

extend(Undo.Stack.prototype, {
execute: function(command) {
execute: async function(command) {
this._clearRedo();
command.execute();
await command.execute();
this.commands.push(command);
this.stackPosition++;
this.changed();
},
undo: function() {
this.commands[this.stackPosition].undo();
this.stackPosition--;
this.changed();
undo: async function() {
if (this.canUndo()) {
await this.commands[this.stackPosition].undo();
this.stackPosition--;
this.changed();
}
},
canUndo: function() {
return this.stackPosition >= 0;
Expand Down Expand Up @@ -115,13 +116,4 @@ Undo.Command.extend = function(protoProps) {
return child;
};

// AMD support
if (typeof define === "function" && define.amd) {
// Define as an anonymous module
define(Undo);
} else if(typeof module != "undefined" && module.exports){
module.exports = Undo
}else {
this.Undo = Undo;
}
}).call(this);
export default Undo;