Closed damonmaria closed 5 years ago
Happy to do a PR.
That sounds like a very good idea. I had thought about is as well, but hadn't really found a use-case for it myself, but this sounds like a very valid one.
Considering, Document has data, and Collection has docs, would you consider hasDocs
to be a better name?
Agreed, hasDocs
is more "does what it says on the can" than hasData
.
I find myself regularly using
collection.docs.length > 0
in my React components. While being verbose it also causes excess re-renders as documents are added and removed, changing the length butlength > 0
is still true.What if there was a
@computed hasData(): boolean
property onCollection
that internally did this check. This would then match the definition ofDocument.hasData
("True whenever the collection has any docs") and would solve the re-rendering issue.