fnpjs: actions - action returns via callback
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 22 Apr 2014 10:33:55 +0000 (12:33 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 23 Apr 2014 11:05:05 +0000 (13:05 +0200)
This allows asynchronous action execution

src/fnpjs/actions.js

index c49373a..f380ed6 100644 (file)
@@ -72,10 +72,11 @@ _.extend(Action.prototype, Backbone.Events, {
         }
         return this._cache;
     },
-    execute: function() {
+    execute: function(callback) {
         var state = this.getState();
+        callback = callback || function() {};
         if(state.allowed) {
-            return state.execute.call(this, this.params, this.appObject);
+            return state.execute.call(this, callback, this.params, this.appObject);
         }
         throw new Error('Execution not allowed');
     }