-
Notifications
You must be signed in to change notification settings - Fork 911
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race conditions with BDC dashboard init (#8135)
* Fix race conditions with initialized * Check for undefined status * Disable no-floating-promises check * Add catch instead of disabling tslint disable
- Loading branch information
1 parent
6864d39
commit a8eed61
Showing
5 changed files
with
109 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the Source EULA. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Deferred } from '../../common/promise'; | ||
|
||
export abstract class BdcDashboardPage { | ||
|
||
private _initialized: boolean = false; | ||
|
||
private onInitializedPromise: Deferred<void> = new Deferred(); | ||
|
||
constructor() { } | ||
|
||
protected get initialized(): boolean { | ||
return this._initialized; | ||
} | ||
|
||
protected set initialized(value: boolean) { | ||
if (!this._initialized && value) { | ||
this._initialized = true; | ||
this.onInitializedPromise.resolve(); | ||
} | ||
} | ||
|
||
/** | ||
* Runs the specified action when the component is initialized. If already initialized just runs | ||
* the action immediately. | ||
* @param action The action to be ran when the page is initialized | ||
*/ | ||
protected eventuallyRunOnInitialized(action: () => void): void { | ||
if (!this._initialized) { | ||
this.onInitializedPromise.promise.then(() => action()).catch(error => console.error(`Unexpected error running onInitialized action for BDC Page : ${error}`)); | ||
} else { | ||
action(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters