Skip to content

Commit

Permalink
Implement job:update event
Browse files Browse the repository at this point in the history
  • Loading branch information
THE-SIMPLE-MARK committed Feb 29, 2024
1 parent 9124a20 commit 080e350
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ classes are documented here.
- [Event: `client:disconnect`](#clientdisconnect)
- [Event: `printer:dataUpdate`](#printerdataupdate)
- [Event: `printer:statusUpdate`](#printerstatusupdate)
- [Event: `job:update`](#jobupdate)
- [Event: `job:start`](#jobstart)
- [Event: `job:pause`](#jobpause)
- [Event: `job:unpause`](#jobunpause)
Expand Down Expand Up @@ -169,6 +170,10 @@ field.

Triggered whenever the printer's status changes to a new status.

#### `job:update`

Triggered whenever the current Job's data gets updated.

#### `job:start`

Triggered whenever a new printing job starts.
Expand Down
6 changes: 5 additions & 1 deletion src/BambuClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ export class BambuClient extends events.EventEmitter<keyof BambuClientEvents> {
this._printerStatus = data.print.gcode_state

// update job data
if (this.currentJob) this.currentJob.update(data.print)
if (this.currentJob) {
this.currentJob.update(data.print)

this.emit("job:update", this.currentJob)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/BambuClientEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface BambuClientEvents {
oldStatus: BambuClientPrinterStatus,
newStatus: BambuClientPrinterStatus,
]
"job:update": [job: Job]
"job:start": [job: Job]
"job:pause": [job: Job]
"job:offlineRecovery": [job: Job]
Expand Down

0 comments on commit 080e350

Please sign in to comment.