@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
45 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScheduleWork = void 0;
const index_js_1 = require("../../abilities/index.js");
const index_js_2 = require("../models/index.js");
/**
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) that enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/) to schedule a callback function
* to be executed with a delay, or until some condition is met.
*
* Used internally by the [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Wait`](https://serenity-js.org/api/core/class/Wait/).
*
* @experimental
*
* @group Time
*/
class ScheduleWork extends index_js_1.Ability {
scheduler;
constructor(clock, interactionTimeout) {
super();
this.scheduler = new index_js_2.Scheduler(clock, interactionTimeout);
}
/**
* @param callback
* @param limits
*/
repeatUntil(callback, limits) {
return this.scheduler.repeatUntil(callback, limits);
}
waitFor(delay) {
return this.scheduler.waitFor(delay);
}
discard() {
this.scheduler.stop();
}
toJSON() {
return {
...super.toJSON(),
options: {
scheduler: this.scheduler.toJSON(),
},
};
}
}
exports.ScheduleWork = ScheduleWork;
//# sourceMappingURL=ScheduleWork.js.map