Documentation
Guide
Deleting Task

Deleting Task

Handling and managing tasks is a critical part of any application, and at times it's necessary to clean up tasks that are no longer needed. Deleting a task in Kronash is straightforward and can be done in a single line of code.

To delete a task, use the clear method from your Kronash instance and pass in the name of the task that you wish to remove:

kronash.clear('myTask');
// or
kronash.create(options).start().clear();

In this example, the task named 'myTask' will be cleared.

Notes

  1. The task you are trying to delete should exist. Attempting to delete a nonexistent task will throw an error. Always ensure the task was created and is currently available before trying to delete it.

  2. When a task is cleared, if it's currently active (running), it will be immediately stopped, and then removed. The onEnd callback won't be invoked in this case since the task didn't naturally come to an end but was forcibly stopped.