I have a few questions regarding the 3.0 migration.
- In the code for,say, findOne, it says:
findOne(...args) {
// [FIBERS]
// TODO: Remove this when 3.0 is released.
in 3.0 will all the non async versions be removed? So will findOne no longer be defined in 3.0?
-
in the client currently some mini-mongo functions are synchronous, like findOne. I understand it appears synchronous on the server as well, but just because it is executed in a fiber. Will it still exist and be synchronous on the client in 3.0? If I use findOne in a helper function in Blaze, will that also need to be converted to FindOneAsync on the client? If so and I need to await the result, do I just decorate the helper function with the async keyword?
-
Will Meteor.user() still exist and be synchronous on the client?
thanks,
Cliff
2 Likes
AFAIK the goal is to keep the existent sync API for the client only.
But that will limit some features or cause side effects in some cases.
I think @denyhs @grubba or @hschmaiske can confirm.
This snipped is a TODO I placed myself for removing the method below. We can see the full findOne
implementation in 3.0 as follows:
findOne(...args) {
// [FIBERS]
// TODO: Remove this when 3.0 is released.
warnUsingOldApi(
"findOne",
this._name,
this.findOne.isCalledFromAsync
);
this.findOne.isCalledFromAsync = false;
return this._collection.findOne(
this._getFindSelector(args),
this._getFindOptions(args)
);
},
in 3.0 this function will look like this:
findOne(...args) {
return this._collection.findOne(
this._getFindSelector(args),
this._getFindOptions(args)
);
}
as this was used to help users to make the migration easier. It was commented in the 2.12 blogpost, and I added those comments not to forget later on to remove this code
Regarding the question:
- Will Meteor.user() still exist and be synchronous on the client?
I’m sure that Meteor.userId will stay sync
, for the Meteor.user
. I’m still thinking of ways of how I could do this. I have not given much thought to it.
At the moment that I’m speaking, Meteor.user
will be async as it calls for data in the MongoDB, it may change, but we still need to think about how we could make this change, implementation-wise.
Is there somewhere a list of breaking changes with examples of how to migrate for Meteor 3.0?