Skip to content
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

Refactor some FirestoreClient methods #3507

Merged
merged 2 commits into from
Jul 30, 2020
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

The next PR is going to have a larger diff so this one extracts the change out that I made for two methods. I moved this methods to firestore_client.ts to match the other methods of #3492.

In the follow up PR, I will then drop FirestoreClient from firestore-exp and will directly call the new methods.

@changeset-bot
Copy link

changeset-bot bot commented Jul 29, 2020

💥 No Changeset

Latest commit: b6b38db

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 29, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (6f283d5) Head (2a9d895) Diff
    browser 246 kB 247 kB +637 B (+0.3%)
    esm2017 193 kB 193 kB +275 B (+0.1%)
    main 470 kB 471 kB +1.28 kB (+0.3%)
    module 244 kB 244 kB +593 B (+0.2%)
    react-native 193 kB 193 kB +275 B (+0.1%)
  • @firebase/firestore/exp

    Type Base (6f283d5) Head (2a9d895) Diff
    browser 187 kB 187 kB +261 B (+0.1%)
    main 466 kB 467 kB +1.26 kB (+0.3%)
    module 187 kB 187 kB +261 B (+0.1%)
    react-native 187 kB 187 kB +261 B (+0.1%)
  • @firebase/firestore/memory

    Type Base (6f283d5) Head (2a9d895) Diff
    browser 185 kB 185 kB +637 B (+0.3%)
    esm2017 145 kB 145 kB +275 B (+0.2%)
    main 345 kB 347 kB +1.28 kB (+0.4%)
    module 183 kB 183 kB +593 B (+0.3%)
    react-native 145 kB 145 kB +275 B (+0.2%)
  • firebase

    Type Base (6f283d5) Head (2a9d895) Diff
    firebase-firestore.js 285 kB 285 kB +589 B (+0.2%)
    firebase-firestore.memory.js 225 kB 226 kB +589 B (+0.3%)
    firebase.js 818 kB 819 kB +593 B (+0.1%)

Test Logs

@@ -65,7 +63,7 @@ export function getDoc<T>(
const ref = cast<DocumentReference<T>>(reference, DocumentReference);
const firestore = cast<Firestore>(ref.firestore, Firestore);
return getFirestoreClient(firestore).then(async firestoreClient => {
const viewSnapshot = await getDocViaSnapshotListener(
const viewSnapshot = await firestoreClient.getDocumentFromLocalCache(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this use getDocumentFromLocalCache and not getDocumentViaSnapshotListener like the other refactorings in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug. Thanks for catching.

@@ -415,6 +418,20 @@ export class FirestoreClient {
);
}

async getDocumentViaSnapshotListener(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: consider something like getSingleDocumentViaSnapshotListener. As it stands, these function names are really similar to each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the name that was used previously and matches other SDKs, such as Android. I am leaving as is for consistency.

@schmidt-sebastian schmidt-sebastian merged commit 94986e6 into master Jul 30, 2020
@firebase firebase locked and limited conversation to collaborators Aug 30, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/smallerdiff branch November 9, 2020 22:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants