TaskManager
Import :
const TaskManager = brackets.getModule("features/TaskManager")
features/TaskManager
TaskManager module deals with managing long running tasks in phcode. It handles the Tasks
dropdown in the status
bar where the user can see all running tasks, monitor its progress and close/pause the execution of the task if
supported by the task.
- features/TaskManager
- .addNewTask(taskTitle, message, [iconHTML], [options]) ⇒
TaskObject
- .TaskObject :
Object
- .addNewTask(taskTitle, message, [iconHTML], [options]) ⇒
features/TaskManager.addNewTask(taskTitle, message, [iconHTML], [options]) ⇒ TaskObject
The addNewTask is designed for adding new tasks to the task management system. This function is central to managing long-running tasks, providing a way to visually represent task progress, status, and control actions directly from the UI in the status bar.
Kind: inner method of features/TaskManager
Returns: TaskObject
- Returns a task object with methods for updating the task's state and UI representation,
such as setProgressPercent
, setMessage
, setSucceeded
, setFailed
, and control visibility methods
like showStopIcon
, hideStopIcon
, etc.
Param | Type | Default | Description |
---|---|---|---|
taskTitle | string | The title of the task. This is a mandatory parameter and is displayed in the UI. | |
message | string | A message or status associated with the task. Displayed as additional information in the UI. | |
[iconHTML] | string | null | Optional HTML string for the task's icon. Used to visually represent the task in the UI. |
[options] | Object | Optional settings and callbacks for the task. | |
[options.onPauseClick] | function | Callback function triggered when the pause button is clicked. | |
[options.onPlayClick] | function | Callback function triggered when the play button is clicked. | |
[options.onStopClick] | function | Callback function triggered when the stop button is clicked. | |
[options.onRetryClick] | function | Callback function triggered when the retry button is clicked. | |
[options.onSelect] | function | Callback function triggered when the task is selected from the dropdown. | |
[options.progressPercent] | number | Initial progress percentage of the task. | |
[options.noSpinnerNotification] | boolean | If set to true, will not show the task spinners for this task. This can be used for silent background tasks where user attention is not needed. |
Example
// Example: Adding a new task with initial progress and attaching event handlers
const task = TaskManager.addNewTask(
'Data Processing',
'Processing data...',
'<i class="fa fa-spinner fa-spin"></i>',
{
onPauseClick: () => console.log('Task paused'),
onPlayClick: () => console.log('Task resumed'),
onStopClick: () => console.log('Task stopped'),
onRetryClick: () => console.log('Task retried'),
onSelect: () => console.log('Task selected'),
progressPercent: 20
}
);
// Updating task progress
task.setProgressPercent(60);
// Updating task message
task.setMessage('60% completed');
// Marking task as succeeded
task.setSucceeded();
features/TaskManager.TaskObject : Object
Methods for managing the task's state and UI representation in the TaskManager.
Kind: inner typedef of features/TaskManager
Properties
Name | Type | Description |
---|---|---|
show | function | Shows the task popup in the ui. |
close | function | Closes the task and removes it from the UI. |
setTitle | function | Sets the task's title. |
getTitle | function | Returns the task's title. |
setMessage | function | Sets the task's message. |
getMessage | function | Returns the task's message. |
setProgressPercent | function | Sets the task's progress percentage. |
getProgressPercent | function | Returns the task's current progress percentage. |
setFailed | function | Marks the task as failed. |
isFailed | function | Returns true if the task is marked as failed. |
setSucceded | function | Marks the task as succeeded. |
isSucceded | function | Returns true if the task is marked as succeeded. |
showStopIcon | function | Shows the stop icon with an optional tooltip message. |
hideStopIcon | function | Hides the stop icon. |
showPlayIcon | function | Shows the play icon with an optional tooltip message. |
hidePlayIcon | function | Hides the play icon. |
showPauseIcon | function | Shows the pause icon with an optional tooltip message. |
hidePauseIcon | function | Hides the pause icon. |
showRestartIcon | function | Shows the restart (retry) icon with an optional tooltip message. |
hideRestartIcon | function | Hides the restart (retry) icon. |
flashSpinnerForAttention | function | briefly flashes the task spinner icon for attention. |