feat(task): any data can be attached to the task

Previously, only `name` was accepted.
This commit is contained in:
Julien Fontanet
2023-04-17 11:29:05 +02:00
parent 12552a1391
commit 036f3f6bd0
3 changed files with 14 additions and 4 deletions

View File

@@ -2,7 +2,12 @@
import { Task } from '@vates/task'
const task = new Task({
name: 'my task',
// data in this object will be sent along the *start* event
//
// property names should be chosen as not to clash with properties used by `Task` or `combineEvents`
data: {
name: 'my task',
},
// if defined, a new detached task is created
//

View File

@@ -18,7 +18,12 @@ npm install --save @vates/task
import { Task } from '@vates/task'
const task = new Task({
name: 'my task',
// data in this object will be sent along the *start* event
//
// property names should be chosen as not to clash with properties used by `Task` or `combineEvents`
data: {
name: 'my task',
},
// if defined, a new detached task is created
//

View File

@@ -84,8 +84,8 @@ exports.Task = class Task {
return this.#status
}
constructor({ name, onProgress }) {
this.#startData = { name }
constructor({ data = {}, onProgress }) {
this.#startData = data
if (onProgress !== undefined) {
this.#onProgress = onProgress