We are using Firebase Firestore and Cloud functions as a backend for a Flutter app. The app gets most of the data directly from Firestore (with security rules), while some data moves through cloud functions. We are considering creating an API for our product, i.e. making the app interact with the cloud functions only.
One problem we are facing is observing object state. The Firestore library allows for easy streaming of documents, i.e reference.document(id).snapshots() returns a Stream, but cloud functions are not observable, and also have a lifetime of up to 9 minutes. Is there a good practice to transmit Firestore document changes from the backend into the app?