api.intercept()
Description
Allows intercepting and preventing the inner events
Usage
api.intercept(
event: string,
callback: function
): void;
Parameters
event
- (required) the event to be firedcallback
- (required) a callback to be performed (the callback 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
});
// forbid removing a project with the "first" ID
list.api.intercept("delete-project", ({ id }) => {
if(id == "first"){
return false;
}
});