Skip to content

Commit

Permalink
CB-4767 feat: async status read API
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Mar 28, 2024
1 parent 73176aa commit 1105f13
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions webapp/packages/core-sdk/src/AsyncTask/AsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
import { computed, makeObservable, observable } from 'mobx';

import { type ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { uuid } from '@cloudbeaver/core-utils';

import type { AsyncTaskInfo } from '../sdk';
Expand All @@ -31,6 +32,8 @@ export class AsyncTask {
return this.innerPromise;
}

readonly onStatusChange: ISyncExecutor<AsyncTaskInfo>;

private _cancelled: boolean;
private taskInfo: AsyncTaskInfo | null;
private resolve!: (value: AsyncTaskInfo) => void;
Expand All @@ -49,6 +52,7 @@ export class AsyncTask {
this.updatingAsync = false;
this.taskInfo = null;
this.initPromise = null;
this.onStatusChange = new SyncExecutor();

this.innerPromise = new Promise((resolve, reject) => {
this.reject = reject;
Expand Down Expand Up @@ -125,6 +129,7 @@ export class AsyncTask {
this.resolve(info);
}
}
this.onStatusChange.execute(this.taskInfo);
}

private async cancelTask(): Promise<void> {
Expand Down

0 comments on commit 1105f13

Please sign in to comment.