Hi Peter -
First off, wow! I don't think I've seen Firebase and Google Sheets wired-up before - very neat!
I can't say for sure, but I suspect that this isn't currently possible based upon restrictions imposed by Google Sheets. The Firebase JavaScript client library assumes either a full browser or full Node.js environment, and Sheets likely doesn't conform. That said, there's a couple things we could try:
- If you manage to get all Firebase client code into Sheets somehow, you can manually play with the transports that we'll use to connect to the server, using either Firebase.INTERNAL.forceLongPolling() or Firebase.INTERNAL.forceWebSockets().
- I'm not bearish on it working since it is a long-lived socket that periodically emits data, but Firebase REST API Streaming is intended to be used when you cannot use a client but want to be able to create a listener.
My hunch is that you'll have to solve this by periodically polling Firebase for changes via the REST API, just like how you're writing to Firebase in the code snippet above. You could fetch data from Firebase on some regular interval, say every N seconds.
If you go the polling route, you might find that you're constantly downloading the same data which - if large - might be expensive or slower than you'd like. Consider expanding your solution to actually do two writes - write the data to one location, and write a signaling mechanism to another. In this case, your polling-based listener could periodically check the signaling location that only stores some lightweight data (such as the most recent timestamp of a broader change) and only if some criteria is met (such as your local client no longer having the latest version, or most recent timestamp) would you go fetch the "full" data.
Hope that helps! Let us know what you come up with.
Thanks -
Rob DiMarco
Engineer @ Firebase