|
@@ -6,22 +6,7 @@
|
|
|
|
|
|
import Task from '../task'
|
|
|
import RuntimeContext from './runtime-context'
|
|
|
-
|
|
|
-interface Progress {
|
|
|
- taskId: number,
|
|
|
- elapsedMs: { real: number, cpu: number },
|
|
|
- tree: Progress.Node,
|
|
|
- tryAbort?: () => void
|
|
|
-}
|
|
|
-
|
|
|
-namespace Progress {
|
|
|
- export interface Node {
|
|
|
- readonly progress: Task.Progress,
|
|
|
- readonly children: ReadonlyArray<Node>
|
|
|
- }
|
|
|
-
|
|
|
- export interface Observer { (progress: Progress): void }
|
|
|
-}
|
|
|
+import Progress from './progress'
|
|
|
|
|
|
class ObservableExecutor {
|
|
|
async run<T>(task: Task<T>): Promise<T> {
|
|
@@ -31,7 +16,7 @@ class ObservableExecutor {
|
|
|
try {
|
|
|
return await task.__f(ctx);
|
|
|
} catch (e) {
|
|
|
- if (e === Task.Aborted) task.__onAbort();
|
|
|
+ if (Task.isAborted(e)) task.__onAbort();
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
@@ -44,7 +29,7 @@ class ObservableExecutor {
|
|
|
class ObservableRuntimeContext implements RuntimeContext {
|
|
|
id: number = 0;
|
|
|
requiresUpdate: boolean = false;
|
|
|
- update(progress: Partial<RuntimeContext.ProgressUpdate>): Promise<void> {
|
|
|
+ update(progress: Partial<RuntimeContext.ProgressUpdate>): Promise<void> {
|
|
|
return 0 as any;
|
|
|
}
|
|
|
runChild<T>(progress: Partial<RuntimeContext.ProgressUpdate>, task: Task<T>): Promise<T> {
|
|
@@ -60,4 +45,4 @@ namespace ExecuteObservable {
|
|
|
export let PRINT_ERRORS_TO_CONSOLE = false;
|
|
|
}
|
|
|
|
|
|
-export { ExecuteObservable, Progress }
|
|
|
+export default ExecuteObservable
|