Open BrianChapman opened 5 years ago
This is great, I'm glad I found this because I really needed this functionality in tests, however in it's current state I don't think it'll quite work yet.
The functionality missing (or not quite working) is that:
onShapshot
it should return the current state of the document / collection, not just when something changes..where(...)
it doesn't seem to work at all.I think 2 is more related to a fundamental issue with this mocking library in that where()
seems to resolve immediately, whereas in the real library it returns a lazy ref that must be resolved with get()
.
@derekparker I updated this to return both immediately and when something changes. I'm not sure then where operator is fully implemented.
These changes work well in my project.
Is there a reason this PR hasn't been able to be merged yet?
EDIT: Nevermind, I did notice an issue with the code: the onSnapshot callback sometimes wasn't called with the initial contents (if value was null at the time, or if called on a dec-ref instead of a query).
Created a new pull-request which resolves those issues: https://github.com/soumak77/firebase-mock/pull/158
Implements onSnapshot. See https://github.com/soumak77/firebase-mock/issues/81