More questions about meteor 3.0

I have a few questions regarding the 3.0 migration.

  1. 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?

  1. 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?

  2. 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.

  1. There was a plan to remove them some time ago; now it shifted toward keeping them but as async ones. You can read more in Mongo: Add deprecation tags to deprecated methods by alisnic · Pull Request #12592 · meteor/meteor · GitHub.
  2. In the same discussion I linked above, @grubba suggested that there may be a new set of methods for this purpose. However, there’s also a Blaze async workgroup, resulting in Implemented async bindings in `#let`. by radekmie · Pull Request #412 · meteor/blaze · GitHub and Added support for `Promise`s in `Spacebars.call` and `Spacebars.dot`. by radekmie · Pull Request #413 · meteor/blaze · GitHub (see #blaze-async-workgroup on Slack for more details).
  3. There definitely will be an async version, but I’m not sure whether there will be a sync one. userId() should remain sync, though.
1 Like

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:

  1. 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?