diff options
Diffstat (limited to 'src/scenario/Future.js')
| -rw-r--r-- | src/scenario/Future.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/scenario/Future.js b/src/scenario/Future.js index cc40eff0..60fad9c5 100644 --- a/src/scenario/Future.js +++ b/src/scenario/Future.js @@ -1,13 +1,22 @@ -function Future(name, behavior) { +/** + * A future action in a spec. + */ +angular.scenario.Future = function(name, behavior) { this.name = name; this.behavior = behavior; this.fulfilled = false; - this.value = _undefined; -} + this.value = undefined; +}; -Future.prototype = { - fulfill: function(value) { +/** + * Executes the behavior of the closure. + * + * @param {Function} Callback function(error, result) + */ +angular.scenario.Future.prototype.execute = function(doneFn) { + this.behavior(angular.bind(this, function(error, result) { this.fulfilled = true; - this.value = value; - } + this.value = error || result; + doneFn(error, result); + })); }; |
