Skip to content

Commit

Permalink
missed a file
Browse files Browse the repository at this point in the history
  • Loading branch information
pvh committed Jan 8, 2025
1 parent 5015c44 commit 485f4c7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/automerge-repo/src/FindProgress.ts
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>>
}

0 comments on commit 485f4c7

Please sign in to comment.