'Firebase Listener Called Multiple Times When Data Change SwiftUI
I have three listeners
- Get Visible Data to all user
- Get Data Between two dates
- Get All Data
However, When any Data change user table the Listener call automatically 4-5 times.
func listenData() -> ListenerRegistration {
let listener = db.collection("user")
.whereField("FirstRow", isGreaterThanOrEqualTo: "FirstRow")
.whereField("lastRow", isLessThanOrEqualTo: "lastRow")
.addSnapshotListener { querySnapshot, error in
if let error = error {
print("listener error: \(error.localizedDescription)")
return
}
if let snapshot = querySnapshot {
print("Without For Each = Data")
snapshot.documentChanges.forEach { diff in
print("For Each = Data")
}
print("listen Public Rides Loop Done")
}
}
return listener
}
Question: How to Listener call once time when user change the data?
Can someone please explain to me How to Listener call once time only?
Any help would be greatly appreciated.
Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
