Skip to content

Macro API Doc

Peter edited this page Jul 20, 2023 · 2 revisions

ProgressionEvent

A progression event is a special type of event that is displayed in the notification area of the dashboard.

A progression on dashboard consists of a title, a progress bar, and a progress message.

The progress bar is updated by calling the addProgress or setProgress methods, and completed by calling the complete method.

Note that it is very important to call the complete method for every progression event created. Failure to do so will result in the event being stuck in the dashboard.

It is ok if your elapsed progress is greater than the total progress or less than the total progress, as long as the complete method is called. Dashboard will automatically adjust the progress bar to 100%.

Warning

Please do NOT update the progression event too frequently. The dashboard can only handle a limited number of events per second. The dashboard may experience performance issues if you update the progression event too frequently.

Example

const progression = ProgressionHandler.create(
  "Some long running operation",
  100
);

for (let i = 0; i < 100; i++) {
  progression.setProgress(i, `Progress ${i}`);
  await new Promise((r) => setTimeout(r, 100));
}

progression.complete(true, "Long running operation completed");