Skip to content

Tree-Shake RemoteStore Streams #3568

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

Merged
merged 6 commits into from
Sep 9, 2020
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Aug 5, 2020

This PR changes the remote store to make the streams optional. In the callsites that require the streams, the streams are loaded and registered with the RemoteStore. The RemoteStore then tracks these streams via networkStatusHandlers, which take care of forwarding the calls to disable and enable the network.

This PR also ensures that the mutation queue is drained at startup if persistence is enabled. Unfortunately, this means that clients that use IndexedDb now also always depend on SyncEngine and RemoteStore.

@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2020

💥 No Changeset

Latest commit: 16c995f

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 Aug 5, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (565004d) Head (8872f12) Diff
    browser 248 kB 249 kB +474 B (+0.2%)
    esm2017 196 kB 196 kB -72 B (-0.0%)
    main 482 kB 483 kB +1.22 kB (+0.3%)
    module 246 kB 246 kB +430 B (+0.2%)
    react-native 196 kB 196 kB -72 B (-0.0%)
  • @firebase/firestore/exp

    Type Base (565004d) Head (8872f12) Diff
    browser 189 kB 189 kB -71 B (-0.0%)
    main 477 kB 478 kB +1.55 kB (+0.3%)
    module 189 kB 189 kB -71 B (-0.0%)
    react-native 190 kB 190 kB -71 B (-0.0%)
  • @firebase/firestore/lite

    Type Base (565004d) Head (8872f12) Diff
    browser 64.3 kB 64.3 kB -42 B (-0.1%)
    main 142 kB 141 kB -73 B (-0.1%)
    module 64.3 kB 64.3 kB -42 B (-0.1%)
    react-native 64.6 kB 64.5 kB -42 B (-0.1%)
  • @firebase/firestore/memory

    Type Base (565004d) Head (8872f12) Diff
    browser 186 kB 186 kB +422 B (+0.2%)
    esm2017 147 kB 147 kB -76 B (-0.1%)
    main 356 kB 357 kB +1.10 kB (+0.3%)
    module 184 kB 184 kB +378 B (+0.2%)
    react-native 147 kB 147 kB -76 B (-0.1%)
  • firebase

    Type Base (565004d) Head (8872f12) Diff
    firebase-firestore.js 286 kB 287 kB +428 B (+0.1%)
    firebase-firestore.memory.js 226 kB 226 kB +375 B (+0.2%)
    firebase.js 829 kB 830 kB +432 B (+0.1%)

Test Logs

@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt/splitremotestore branch 2 times, most recently from 112b299 to 8541ba7 Compare August 17, 2020 13:19
@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt/splitremotestore branch from ac2f643 to 981b8a3 Compare September 8, 2020 15:34
@schmidt-sebastian schmidt-sebastian changed the title Tree-Shake RemoteStore Tree-Shake RemoteStore Streams Sep 8, 2020
@schmidt-sebastian schmidt-sebastian changed the base branch from mrschmidt/optionalviews to mrschmidt/queueeverything September 8, 2020 15:34
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 8, 2020

Size Analysis Report

Affected Products

No changes between base commit (565004d) and head commit (8872f12).

Test Logs

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

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

LGTM with some naming ideas.

* Registers a callback function that is invoked when the network status
* changes. Multiple callbacks are supported.
*/
function addNetworkStatusChangedHandler(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this just be onNetworkStatusChange to match other event handlers we have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I inlined this and changed the internal variable name to onNetworkStatusChange.

* PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
* This is not done on Web to allow it to be tree-shaken.
*/
function ensureWatchStream(
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: since this is essentially a lazy-initializing getter, you might want to just call this watchStream to cut verbosity in all the call sites.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this as is since this it would require me to rename all occurrences of writeStream and watchStream (to avoid name clashes at the callsite), which might make the code even more verbose.

@wilhuff wilhuff assigned schmidt-sebastian and unassigned wilhuff Sep 9, 2020
Base automatically changed from mrschmidt/queueeverything to master September 9, 2020 22:18
@schmidt-sebastian schmidt-sebastian merged commit 95ab732 into master Sep 9, 2020
@firebase firebase locked and limited conversation to collaborators Oct 10, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/splitremotestore 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