aboutsummaryrefslogtreecommitdiffstats
path: root/src/scenario/Future.js
blob: 60fad9c5906c07797eac855007bc3b28ffa7bf81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * A future action in a spec.
 */
angular.scenario.Future = function(name, behavior) {
  this.name = name;
  this.behavior = behavior;
  this.fulfilled = false;
  this.value = undefined;
};

/**
 * 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 = error || result;
    doneFn(error, result);
  }));
};