Skip to content

Commit

Permalink
fix(runner): add on_action and on_status for events
Browse files Browse the repository at this point in the history
  • Loading branch information
brewcoua committed Jun 14, 2024
1 parent b212e97 commit 67990a4
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/services/runner/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Runner extends Service {
}
public set status(value: RunnerStatus) {
this._status = value
this.emit('status', value)
super.emit('status', value)
}

public async run(): Promise<TaskResult> {
Expand Down Expand Up @@ -169,7 +169,7 @@ export default class Runner extends Service {

this.logger.info('Performed action', report)

this.emit('action', report)
super.emit('action', report)

return {
success: true,
Expand All @@ -195,4 +195,29 @@ export default class Runner extends Service {
private async sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms))
}

public on_action(
event: 'action',
listener: (action: ActionReport) => void
): this {
return super.on(event, listener)
}
public on_status(
event: 'status',
listener: (status: RunnerStatus) => void
): this {
return super.on(event, listener)
}
public off_action(
event: 'action',
listener: (action: ActionReport) => void
): this {
return super.off(event, listener)
}
public off_status(
event: 'status',
listener: (status: RunnerStatus) => void
): this {
return super.off(event, listener)
}
}

0 comments on commit 67990a4

Please sign in to comment.