firebase / firebase/firebase-js-sdk

FR: Ability to specify snapshot source for onSnapshot

Open
#3,995 8 comments 4 reactions 0 assignees View on GitHub
api: firestore feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### [REQUIRED] Describe your environment

* Operating System version: MacOS catalina
* Browser version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36
* Firebase SDK version: 7.24.0
* Firebase Product: firestore (auth, database, storage, etc)

### [REQUIRED] Describe the problem

I'm trying to build a workaround for:

https://github.com/firebase/firebase-js-sdk/issues/3993

my idea is to implement our own cache and have our snapshot listeners only resolve from the server.

I'm going to build my own IndexedDB cache to put in front of firestore.

The problem is that if I initialize firestore and tell it to use the local cache it will first read from cache (which is super slow for us) and then read from the server.

for get() I can specify a source with GetOptions as 'default' | 'server' | 'cache'

... but I can't do this with onSnapshot.

I'd like to tell it to use 'server' so that the local cache is skipped for certain queries in favor of our own cache.

After that our caching layer will use a write through so that every onNext updates the local cache with the most recent value and pass the recent value onto the listener.

But I'd really love fro you guys to fix https://github.com/firebase/firebase-js-sdk/issues/3993 ... but even if you do I think this is a good feature to have!

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.