existsTask()
Description
Checks whether the specified task exists in DataStore
Usage
existsTask({ id: string | number }): boolean;
Parameters
id
- (required) the ID of the task
Returns
The method returns true
if the task exists; otherwise, false
Example
const { ToDo, Toolbar } = todo;
const { users, projects } = getData();
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1" },
{ id: "1.1", text: "Task 1.1", parent: "1" },
{ id: "1.2", text: "Task 1.2", parent: "1" },
],
users,
projects
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// check whether tasks exist
list.existsTask({ id: "2" }); // -> false
list.existsTask({ id: "1.2" }); // -> true
Related article: Task object/Id