I am trying out Meteor 3.0-rc.2 with an existing project and I am getting a bunch of cursor.observe(...).stop is not a function
in my server tests. Is there an easy fix?
1 Like
Yes. We introduced recently this new API to solve your issue.
observe or observeChange from Meteor 2.x require to be resolved async on Meteor 3.x with observeAsync and observeChangesAsync respectively. This is only mandatory on the server code, on the client you can still use the sync version. However, we encourage to benefit from isomorphism and use async whenever is possible.
Oh great! And I can see the observe*Async
functions have just landed in Meteor 2.16.
1 Like
Have the types at @types/meteor
been updated yet regarding this addition to the API?
Using this to patch the types while waiting for an update:
import {type Mongo} from 'meteor/mongo';
import {type Meteor} from 'meteor/meteor';
declare module 'meteor/mongo' {
namespace Mongo {
interface Cursor<T, U = T> {
observeAsync(callbacks: Mongo.ObserveCallbacks<U>): Promise<Meteor.LiveQueryHandle>;
observeChangesAsync(
callbacks: Mongo.ObserveChangesCallbacks<T>,
options?: { nonMutatingCallbacks?: boolean | undefined },
): Promise<Meteor.LiveQueryHandle>;
}
}
}