Skip to main content

set-project

Description

Fires when changing the active project

info

The event fires when you use the [setProject] method to change the currently active project

Usage

"set-project": ({
id: string | number
}) => void;

Parameters

The callback of the set-project event can take an object with the following parameters:

  • id - (required) the ID of a newly active project
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 "set-project" event
list.api.on("set-project", ({id}) => {
console.log("The active project is changed to", id);
});

Related article: Operations with projects