fake_cloud_firestore
fake_cloud_firestore copied to clipboard
collectionGroup(..).snapshots().listen(..) callback is never called for me
I have a collectionGroup query and I want to listen to the snapshots. This seems to work fine the real Firestore, but not with the FakeFirebaseFirestore. Is this supported by the library?
This is my production code:
_firestore
.collectionGroup('running-games')
.withConverter(
fromFirestore: RunningGame.fromFirestore,
toFirestore: (RunningGame runningGame, options) =>
runningGame.toFirestore(),
)
.snapshots()
.listen((event) {
print("listener called");
});
And my test is adding the required items to the Fake Firestore:
var gameRef = await firestore.collection("games").add({
"name": "Test game",
"owner": "user",
});
await gameRef.collection("running-games").add({
"state": "startup",
"owner": "user",
});
I verified that the data is there with the dump method:
{
"games": {
"ORYf4LUNgSxyAWAn28f2": {
"running-games": {
"LNua2z1BlVZenX8tdVNt": {
"state": "startup",
"owner": "user"
}
},
"name": "Test game",
"owner": "user"
}
}
}
But the listener that should print "listener called" is never called. Is this not supported or is this a bug in the library? Or do I make a mistake somewhere?
The firing mechanism in our library is a bit complicated. So it was probably never implemented. If you manage to make it work, I'll happily review a PR.