UNPKG

@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.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScheduleWork = void 0; const abilities_1 = require("../../abilities"); const models_1 = require("../models"); /** * 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 abilities_1.Ability { scheduler; constructor(clock, interactionTimeout) { super(); this.scheduler = new models_1.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