New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Meteor 3] Mongo.Cursor.observeChanges returns a Promise instead of a query handle #12918
Comments
For the record I suspect that there's a similar issue in |
These are definitely fine on the client (I just checked on Simple Tasks) and there's |
I just noticed the same issue in meteor-publish-composite, which depends on |
I just confirmed it; on the server, it does return a promise. The client is fine. |
The existing implementation of |
Yeah I think my main objection here is the API change. I'd really like to be able to have a project that can run under both Meteor 2 and Meteor 3. For that to work, I think that any of the APIs in Meteor 3 need to also be present in Meteor 2 with the same signatures. We can drop APIs from Meteor 2 that are deprecated (e.g. Meteor 2 has both |
The central concept here is that not returning a promise in version 3 will result in the inability to uphold the existing functionality (which involves tracking the completion of the initial fetch). While the inclusion of observerAsync may not be ideal, it facilitates a gradual migration and aligns with the rest of API modifications. |
I somehow missed that |
Yes, observeAsync and observeChangesAsync were introduced in Meteor 3.x. In Meteor 2.x, it's not merged yet but is slated for release 2.16, expected this week. Here's the pull request. Your point about TypeScript is valid. I'll include that. Thanks. |
With the current alpha release of v3, calling
observeChanges
(at least on the server side - client might be different!) now returns aPromise<LiveQueryHandle>
. Previously, it returned aLiveQueryHandle
directly. This means that it's not possible to write code that works correctly on both v2 and v3.Specifically,
MongoConnection.prototype._observeChanges
is now anasync
function, causing it to return a Promise).It seems ideal, if possible, to continue returning a
LiveQueryHandle
directly rather than returning aPromise
. However, if that's not possible, then I would request renamingobserveChanges
toobserveChangesAsync
and introducing a wrapper in v2 so that there's a clean migration path.The text was updated successfully, but these errors were encountered: