-
Notifications
You must be signed in to change notification settings - Fork 943
Add JSDoc for bundles #4155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSDoc for bundles #4155
Changes from 8 commits
5c653d1
2b34954
399f2a7
ff81706
7ab05ee
21f5cdf
1456277
eebb68b
29e76c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import { DocumentData, LoadBundleTask, Query } from '@firebase/firestore-types'; | ||
|
||
/** | ||
* <code>firebase</code> is a global namespace from which all Firebase | ||
* services are accessed. | ||
|
@@ -8291,10 +8289,28 @@ declare namespace firebase.firestore { | |
*/ | ||
terminate(): Promise<void>; | ||
|
||
/** | ||
* Loads a Firestore bundle into the local cache. | ||
* | ||
* @param bundleData | ||
* An object representing the bundle to be load. Valid objects are `ArrayBuffer`, | ||
* `ReadableStream<Uint8Array>` or `string`. | ||
* | ||
* @return | ||
* A `LoadBundleTask` object, which notifies callers with progress update, and completion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "...with progress updates, and..." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* or error events. It can be used as a `Promise<LoadBundleTaskProgress>`. | ||
*/ | ||
loadBundle( | ||
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string | ||
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string | ||
): LoadBundleTask; | ||
|
||
/** | ||
* Reads a Firestore `Query` from local cache that is associated to a given name. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Reads a Firestore "Bundles can contain named queries. These named queries are packaged..." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* | ||
* The named queries are from bundles. They are packaged into bundles on the server side (along | ||
* with resulting documents), and loaded to local cache using `loadBundle`. Once in local | ||
* cache, use this method to extract a `Query` by name. | ||
*/ | ||
namedQuery(name: string): Promise<Query<DocumentData> | null>; | ||
|
||
/** | ||
|
@@ -8303,31 +8319,77 @@ declare namespace firebase.firestore { | |
INTERNAL: { delete: () => Promise<void> }; | ||
} | ||
|
||
export interface LoadBundleTask { | ||
/** | ||
* Represents the task of loading a Firestore bundle. It provides progress of bundle | ||
* loading, as well as task completion and error events. | ||
* | ||
* The API is compatible with `Promise<LoadBundleTaskProgress>`. | ||
*/ | ||
export interface LoadBundleTask extends PromiseLike<LoadBundleTaskProgress> { | ||
/** | ||
* Registers functions to listen to bundle loading progress events. | ||
* @param next | ||
* Called when there is a progress update from bundle loading, typically `next` calls occur | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...from bundle loading. Typically, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* each time a Firestore document is loaded from the bundle. | ||
* @param error | ||
* Called when an error occurs during bundle loading. The task aborts after reporting the | ||
* error, and there should be no more updates after this. | ||
* @param complete | ||
* Called when the loading task is complete. | ||
*/ | ||
onProgress( | ||
next?: (progress: LoadBundleTaskProgress) => any, | ||
error?: (error: Error) => any, | ||
complete?: () => void | ||
): void; | ||
|
||
/** | ||
* Implements the `Promise<LoadBundleTaskProgress>.then` interface. | ||
* | ||
* @param onFulfilled | ||
* Called on the completion with a `LoadBundleTaskProgress` update when the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one was a little unclear. Maybe this edit will help, but please clarify "the completion of" what? Completion of the progress update? "Called on completion of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* loading task completes. The update will have its `taskState` set to `"Success"`. | ||
* @param onRejected | ||
* Called when an error occurs during bundle loading. | ||
*/ | ||
then<T, R>( | ||
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>, | ||
onRejected?: (a: Error) => R | PromiseLike<R> | ||
): Promise<T | R>; | ||
|
||
/** | ||
* Implements the `Promise<LoadBundleTaskProgress>.catch` interface. | ||
* | ||
* @param onRejected | ||
* Called when an error occurs during bundle loading. | ||
*/ | ||
catch<R>( | ||
onRejected: (a: Error) => R | PromiseLike<R> | ||
): Promise<R | LoadBundleTaskProgress>; | ||
} | ||
|
||
/** | ||
* Represents a progress update or a final state from loading bundles. | ||
*/ | ||
export interface LoadBundleTaskProgress { | ||
/** How many documents have been loaded. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that you removed these in the other PR. You should leave the comments in both places as firestore-exp builds its d.ts file from source. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that was a bad merge i think. Will keep the comments. |
||
documentsLoaded: number; | ||
/** How many documents are in the bundle being loaded. */ | ||
totalDocuments: number; | ||
/** How many bytes have been loaded. */ | ||
bytesLoaded: number; | ||
/** How many bytes are in the bundle being loaded. */ | ||
totalBytes: number; | ||
/** Current task state. */ | ||
taskState: TaskState; | ||
} | ||
|
||
/** | ||
* Represents the state of bundle loading tasks. | ||
* | ||
* Both 'Error' and 'Success' are sinking state: task will abort or complete and there will | ||
* be no more updates after they are reported. | ||
*/ | ||
export type TaskState = 'Error' | 'Running' | 'Success'; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...bundle to be loaded. Valid..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.