use of com.google.cloud.firestore.ListenerRegistration in project java-docs-samples by GoogleCloudPlatform.
the class ListenDataSnippets method detachListener.
/**
* Demonstrate how to detach an event listener.
*/
void detachListener() {
// [START detach_errors]
Query query = db.collection("cities");
ListenerRegistration registration = query.addSnapshotListener(new EventListener<QuerySnapshot>() {
// [START_EXCLUDE]
@Override
public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirestoreException e) {
}
});
// ...
// Stop listening to changes
registration.remove();
// [END detach_errors]
}
Aggregations