Closed reedom closed 3 years ago
For the client side performance improvement, I want to have "docChanges" on "onQuery" and other "on" series. https://firebase.google.com/docs/firestore/query-data/listen#view_changes_between_snapshots
To achieve it, I think there are several API candidates while the docChanges should be supplied optionally for performance reasons.
Introduce variant functions for each "on" series. E.g. onQueryWithDocChanges for onQuery
onQueryWithDocChanges
onQuery
export default function onQueryWithDocChanges<Model>( collection: Collection<Model> | CollectionGroup<Model>, queries: Query<Model, keyof Model>[], onResult: (docs: Doc<Model>[], docChanges: DocChange<Model>[]), onError?: (err: Error) => any ): () => void {
Add an options specification argument to let clients specify their requirement
options
export default function onQuery<Model>( collection: Collection<Model> | CollectionGroup<Model>, queries: Query<Model, keyof Model>[], onResult: (docs: Doc<Model>[], extra?: { docChanges?: DocChange<Model>[] }), onError?: (err: Error) => any, options?: { docChanges?: boolean } ): () => void {
Add an "getter" to onResult's argument
onResult
export default function onQuery<Model>( collection: Collection<Model> | CollectionGroup<Model>, queries: Query<Model, keyof Model>[], onResult: (docs: Doc<Model>[], getDocChanges: () => DocChange<Model>[]) => any, onError?: (err: Error) => any ): () => void {
A sample implementation to the 3rd. https://github.com/kossnocorp/typesaurus/compare/master...reedom:feature/docchanges?expand=1 But as reviewing Firebase.QuerySnapshot now again, chances are that someone might want to get readTime. So, the 2nd would be better while it's expandable.
Firebase.QuerySnapshot
readTime
I love it, and I agree that the 2nd option works the best. I will happily accept a pull-request and help if it would be needed.
For the client side performance improvement, I want to have "docChanges" on "onQuery" and other "on" series. https://firebase.google.com/docs/firestore/query-data/listen#view_changes_between_snapshots
To achieve it, I think there are several API candidates while the docChanges should be supplied optionally for performance reasons.
Introduce variant functions for each "on" series. E.g.
onQueryWithDocChanges
foronQuery
Add an
options
specification argument to let clients specify their requirementAdd an "getter" to
onResult
's argumentA sample implementation to the 3rd. https://github.com/kossnocorp/typesaurus/compare/master...reedom:feature/docchanges?expand=1 But as reviewing
Firebase.QuerySnapshot
now again, chances are that someone might want to getreadTime
. So, the 2nd would be better while it's expandable.