add-task
Description
Fires when adding a new task
Usage
"add-task": ({
id: string | number,
parent?: string | number | null,
project?: string | number | null,
targetId?: string | number,
reverse?: boolean,
task: object
}) => void;
Parameters
The callback of the add-task event can take an object with the following parameters:
id
- (required) the ID of the added taskparent
- (optional) the ID of the parent taskproject
- (optional) the ID of the projecttargetId
- (optional) the ID of the target taskreverse
- (optional) true, if the task is added before the target task; otherwise, falsetask
- (required) the object of the added task
info
To handle the inner events, you can use the Event Bus methods
Example
const { ToDo, Toolbar } = todo;
const {tasks, projects, users} = getData();
const list = new ToDo("#root", {
tasks,
projects,
users
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// subscribe to the "add-task" event
list.api.on("add-task", (obj) => {
console.log("A new task is added", obj);
});
Related article: Operations with tasks