-
Notifications
You must be signed in to change notification settings - Fork 939
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 6 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 |
---|---|---|
|
@@ -8291,10 +8291,26 @@ 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, could be a `ArrayBuffer`, | ||
* a `ReadableStream<Uint8Array>` or a `string`. | ||
* | ||
* @return A `LoadBundleTask` object, which notifies callers with progress update, completion | ||
* or error event. It can be used as a `Promise<LoadBundleTaskProgress>`. | ||
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. "...notifies callers with progress updates, and completion or error events." 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. |
||
*/ | ||
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 named query from local cache." 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. Here it actually reads a Query object, I added back ticks to make it clear. |
||
* | ||
* The named queries are from bundles, and saved as a result of `loadBundle`. `namedQuery` | ||
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. Something like: 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..more or less similar. |
||
* retrieves the queries used to built the bundles, saving the need to manually construct | ||
* those queries. | ||
*/ | ||
namedQuery(name: string): Promise<Query<DocumentData> | null>; | ||
|
||
/** | ||
|
@@ -8303,31 +8319,71 @@ declare namespace firebase.firestore { | |
INTERNAL: { delete: () => Promise<void> }; | ||
} | ||
|
||
export interface LoadBundleTask { | ||
/** | ||
* Represents the task of loading a Firestore bundle. It provides progress of the bundle | ||
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. "...provides progress of bundle loading, as well as task completion and error events." 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 completion and error events should they be any. | ||
* | ||
* The API is compatible with `Promise<LoadBundleTaskProgress>`. | ||
*/ | ||
export interface LoadBundleTask extends PromiseLike<LoadBundleTaskProgress> { | ||
/** | ||
* Registers functions to listen to bundle loading progresses. | ||
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. "...to listen to bundle loading progress events." 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. |
||
* @param next Called there is a progress update from bundle loading, typically whenever | ||
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. "Called when there is a.... Typically, next calls occur each time a Firestore document is loaded from the bundle." 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. |
||
* a Firestore document is loaded it will generate a progress update. | ||
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. Please fix indent to match the rest of this file. 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. |
||
* @param error Called when there is an error occurred from loading the bundle. The task | ||
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. "Called when an error occurs during bundle loading...." Hmm, if there are important edge cases in "there should be no more updates after this" then let's add? 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. Not sure what you mean by second statement. |
||
* 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 It is called with the compeltion `LoadBundleTaskProgress` 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. Remove "It is..." in both params and start with "Called..." Are there status codes for LoadBundleTaskProgress termination? For unFulfilled: "Called on completion of 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. There is no status code. |
||
* loading task completes. | ||
* @param onRejected It is called when there is an error occurred from loading the bundle. | ||
*/ | ||
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 It is called when there is an error occurred from loading the bundle. | ||
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. See above... 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, but without mentioning status code. |
||
*/ | ||
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.
"...representing the bundle to be loaded. Valid objects are
ArrayBuffer
,ReadableStream<Uint8Array>
orstring
."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.