-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure createWindow is never called before the app is ready
- Loading branch information
Showing
2 changed files
with
56 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Taken from HTTP Toolkit UI's util/promise.ts: | ||
|
||
export interface Deferred<T> { | ||
resolve: (arg: T) => void, | ||
reject: (e?: Error) => void, | ||
promise: Promise<T> | ||
} | ||
|
||
export function getDeferred<T = void>(): Deferred<T> { | ||
let resolve: undefined | ((arg: T) => void) = undefined; | ||
let reject: undefined | ((e?: Error) => void) = undefined; | ||
|
||
let promise = new Promise<T>((resolveCb, rejectCb) => { | ||
resolve = resolveCb; | ||
reject = rejectCb; | ||
}); | ||
|
||
// TS thinks we're using these before they're assigned, which is why | ||
// we need the undefined types, and the any here. | ||
return { resolve, reject, promise } as any; | ||
} |