@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
41 lines • 1.23 kB
JavaScript
import { Ability } from '../../abilities/index.js';
import { Scheduler } from '../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
*/
export class ScheduleWork extends Ability {
scheduler;
constructor(clock, interactionTimeout) {
super();
this.scheduler = new 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(),
},
};
}
}
//# sourceMappingURL=ScheduleWork.js.map