Progress.run() method
>e; This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. >e;
creates a new progress object and runs the given function with the progress as parameter, returns the created progress object.
the function should report progress and call progress.resolve
/ progress.reject
once done.
Signature:
static run<Result = unknown, CurrentProgress = unknown>(fn: (progress: Progress<Result, CurrentProgress>) => unknown, initialProgress: CurrentProgress): Progress<Result, CurrentProgress>;
Parameters
Parameter | Type | Description |
---|---|---|
fn | (progress: Progress<Result, CurrentProgress>) => unknown | |
initialProgress | CurrentProgress |
Returns:
Progress<Result, CurrentProgress>
Example
Progress.run((progress) => {
progress.report(100)
progress.resolve('hello')
}, 0)