mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-20 18:59:37 +00:00
Update:JSDocs for task manager
This commit is contained in:
parent
5644a40a03
commit
6f65350269
8 changed files with 64 additions and 23 deletions
|
|
@ -1,15 +1,27 @@
|
|||
const SocketAuthority = require('../SocketAuthority')
|
||||
const Task = require('../objects/Task')
|
||||
|
||||
class TaskManager {
|
||||
constructor() {
|
||||
/** @type {Task[]} */
|
||||
this.tasks = []
|
||||
}
|
||||
|
||||
/**
|
||||
* Add task and emit socket task_started event
|
||||
*
|
||||
* @param {Task} task
|
||||
*/
|
||||
addTask(task) {
|
||||
this.tasks.push(task)
|
||||
SocketAuthority.emitter('task_started', task.toJSON())
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove task and emit task_finished event
|
||||
*
|
||||
* @param {Task} task
|
||||
*/
|
||||
taskFinished(task) {
|
||||
if (this.tasks.some(t => t.id === task.id)) {
|
||||
this.tasks = this.tasks.filter(t => t.id !== task.id)
|
||||
|
|
@ -17,4 +29,4 @@ class TaskManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
module.exports = TaskManager
|
||||
module.exports = new TaskManager()
|
||||
Loading…
Add table
Add a link
Reference in a new issue