cursor.forEach Documentation Example Does Not Work #528
Comments
@meawoppl, this is a bug. I'm surprised it went uncaught for so long :) forEach (and other cursor accessors) currently call observe() under the hood to implement reactivity, so they currently don't work on cursors that contain skip and limit clauses when called from inside a reactive context. We will fix this. Subsetting the data on the server as you suggest is a good workaround if it works in your application (if you don't need to drive two different client-side widgets with the same records with different limits.) The leaderboard example does this, for example. |
While this doesn't address your point that the documented example Just Doesn't Work, you can also pass the |
Any ETA for implementing reactivity on limit: queries? Google seems to indicate that this has been on the radar since April (http://stackoverflow.com/questions/10157454/meteor-cannot-observe-queries-with-skip-or-limit) |
Is this |
This is now implemented on devel in c10dd19, and will be in the next release. Thanks for the report! |
Woo Good work and thanks! |
In the cursor.forEach example the example code does not run as the description suggests it will, in particular:
"When called in a reactive context, forEach registers dependencies on the matching documents."
This particular example uses limit, and hence the console log will report:
"Uncaught Error: cannot observe queries with skip or limit "
Perhaps not technically wrong, but for certain a bit misleading. As an aside, is there a clean workaround for this? I suppose I can make a server-side collection that is a fraction of the larger one then use that on client side . . .
The text was updated successfully, but these errors were encountered: