-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { DocHandle } from "./DocHandle.js" | ||
|
||
export type FindProgressState = | ||
| "loading" | ||
| "ready" | ||
| "failed" | ||
| "aborted" | ||
| "unavailable" | ||
|
||
interface FindProgressBase<T> { | ||
state: FindProgressState | ||
handle: DocHandle<T> | ||
} | ||
|
||
interface FindProgressLoading<T> extends FindProgressBase<T> { | ||
state: "loading" | ||
progress: number | ||
} | ||
|
||
interface FindProgressReady<T> extends FindProgressBase<T> { | ||
state: "ready" | ||
} | ||
|
||
interface FindProgressFailed<T> extends FindProgressBase<T> { | ||
state: "failed" | ||
error: Error | ||
} | ||
|
||
interface FindProgressUnavailable<T> extends FindProgressBase<T> { | ||
state: "unavailable" | ||
} | ||
|
||
interface FindProgressAborted<T> extends FindProgressBase<T> { | ||
state: "aborted" | ||
} | ||
|
||
export type FindProgress<T> = | ||
| FindProgressLoading<T> | ||
| FindProgressReady<T> | ||
| FindProgressFailed<T> | ||
| FindProgressUnavailable<T> | ||
| FindProgressAborted<T> | ||
|
||
export type FindProgressWithMethods<T> = FindProgress<T> & { | ||
next: () => Promise<FindProgressWithMethods<T>> | ||
// TODO: i don't like this allowableStates | ||
untilReady: (allowableStates: string[]) => Promise<DocHandle<T>> | ||
} |