-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(monaco): make sure monaco is loaded only once (#67)
* perf(monaco): make sure monaco is loaded only once * chore(): add comments in code and clear interval * feat(): create utility classes for monaco
- Loading branch information
Ed Morales
authored
Jun 11, 2019
1 parent
988260d
commit 7df5d9d
Showing
4 changed files
with
58 additions
and
42 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
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,23 @@ | ||
import { Subject, Observable } from 'rxjs'; | ||
|
||
/** | ||
* Waits until monaco has been loaded so we can reference its global object. | ||
*/ | ||
export function waitUntilMonacoReady(): Observable<void> { | ||
let monacoReady$: Subject<void> = new Subject<void>(); | ||
|
||
// create interval to check if monaco has been loaded | ||
let interval: any = setInterval(() => { | ||
if (isMonacoLoaded()) { | ||
// clear interval when monaco has been loaded | ||
clearInterval(interval); | ||
monacoReady$.next(); | ||
monacoReady$.complete(); | ||
} | ||
}, 100); | ||
return monacoReady$.asObservable(); | ||
} | ||
|
||
export function isMonacoLoaded(): boolean { | ||
return typeof((<any>window).monaco) === 'object'; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { TdCodeEditorComponent } from './code-editor.component'; | ||
export { CovalentCodeEditorModule } from './code-editor.module'; | ||
export * from './code-editor.utils'; |