Skip to main content

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 task
  • parent - (optional) the ID of the parent task
  • project - (optional) the ID of the project
  • targetId - (optional) the ID of the target task
  • reverse - (optional) true, if the task is added before the target task; otherwise, false
  • task - (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