Open u12206050 opened 3 months ago
Hi @u12206050 ! Thanks for your proposal. I brought it up with the team, and we think it'd be a useful addition.
While we can't prioritize adding this feature right now, we always welcome contributions. I think you'd need to pass in your adapter instance somewhere (such as PersistentCacheSettings), and then use your adapter here.
Operating System
Windows & OSX
Browser Version
All
Firebase SDK Version
10.13.0
Firebase SDK Product:
Firestore
Describe your project's tooling
Vite, Vue, Web Worker
Describe the problem
We have a had massive success in regards to performance moving all the Firestore logic to a Web worker, however when we implemented it a year ago the only option for persistence was with
persistentSingleTabManager
andforceOwnership: true
. A year on and one of the our most common issues are users opening our app in multiple tabs, and then saying things are not working as expected.It seems currently due to the lack of support of Local Storage in web workers, I propose a simple adapter solution, whereby during the setup of
persistentMultipleTabManager
in the context of a web worker, developers can supply there own local storage adapter, that implements the same interface as the most commonlocalStorage
in modern browsers.The adapter could then handle the messaging part/storage that Firestore requires in order to manage multiple tabs.
Steps and code to reproduce issue
Setup firestore in a Web worker, and use
persistentMultipleTabManager
by default it attempts to use LocalStorage, but ideally can be supplied with an adapter for LocalStorage that could handle cross window messaging.