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

How to listen for realtime updates? #61

Open
piavgh opened this issue Jul 26, 2019 · 4 comments
Open

How to listen for realtime updates? #61

piavgh opened this issue Jul 26, 2019 · 4 comments

Comments

@piavgh
Copy link

piavgh commented Jul 26, 2019

Hi @grahamearley ,

Thank you for making this library. I'm working on a GAS project and I'm glad that there is Firestore now (I was puzzled when I had to choose between MongoDB and Firebase Realtime Database - MongoDB is not realtime, no GAS support, while Firebase Realtime Database is totally sucked)

I checked your document but I can't find how to listen for realtime updates https://firebase.google.com/docs/firestore/query-data/listen

How can I do it with this library? Or if this library can't handle it yet, is there any way to do it manually with GAS?

Thank you.

@willianwelbert
Copy link

@piavgh it's not real time but it might help: on the Google app scripts console go to edit > current project's triggers - there you can configure the function to run every X (even as often as once a minute).
Hope it helps :)

@grahamearley
Copy link
Owner

Hey @piavgh, glad you're interested in the library!

This library doesn't currently have realtime update support. It looks like the Firestore REST API does support realtime updates, as seen here under the firestore.projects.databases.documents.listen group.

If you want to take a look through that reference and make a PR adding realtime support, that would be awesome! In the meantime, perhaps @willianwelbert's idea would work for your use case.

@LaughDonor
Copy link
Collaborator

A quick review seems to make this plausible, a solid starting point would be to check out the Firebase Rest API Realtime Updates page.

There's a lot of good info there, if someone can take the time to make a PR for this!

@rielzzapps
Copy link

The APPS Script has a limited time of being active, so the library itself cannot listen to updates (the script would time-out).

You could trigger the script by webhook, but that means you would have to write a listener somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants