Skip to main content

api.on()

Description​

Allows attaching a handler to the inner events

Usage​

api.on(
event: string,
handler: function
): void;

Parameters​

  • event - (required) the event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)

Events​

info

The full list of the To Do List internal events can be found here

Example​

const { ToDo, Toolbar } = todo;
const { tasks, users, projects } = getData();

// create To do list
const list = new ToDo("#root", {
tasks,
users,
projects
});

// output the project data to console when you remove it
list.api.on("delete-project", ({ id }) => {
console.log( "The id of the project", { id });
});