I noticed a very reputable project returning an empty array from publish when a security or parameter check fails. The comment indicated that returning an empty array would tell the client to remove already published docs. This got me thinking about what I’m doing in similar situations using publish.
Out of curiosity, I went to the docs and looked up publish to see if that is in fact what would happen. I found the docs on publish very lacking. This is one of the most important calls in Meteor! The best answer I could find to my question is in the statement
If a publish function does not return a cursor or array of cursors, it is assumed to be using the low-level added/changed/removed interface, and it must also call ready once the initial record set is complete.
The code I was looking at was not returning an array of cursors, it was returning an empty array. So it falls into the “must call ready” category. But it was never calling “this.ready”. So it actually falls between the cracks in the docs. I can’t discern what it should do.
So I’m curious as to whether the statement in the “publish” documentation is correct. Perhaps returning nothing at all or returning an empty array without calling this.ready clears previously published cursors?
The guide says to call this.ready in a case like this. What effect does that have on an interface that normally returns cursors? Will a call to this.ready without having called this.added, changed, or removed clear all client data?
What happens if nothing is returned and this.ready is never called? This should be in the docs!