Suppose I have this helpers which are attached to a mongodb document :
export {
getChild1() {
return Child1Collection.findOne({ parentId: this._id });
},
isGoodToGo() {
const child1 = this.getChild1();
if (child1.somethingComplex && someMoreComplexity) {
return true;
}
// some more things
return false;
}
}
Till Meteor v2 this works as we have fiber support, but since now are migrating to v3, we have to update helpers to something like this
export {
async getChild1() {
return Child1Collection.findOneAsync({ parentId: this._id });
},
async isGoodToGo() {
const child1 = await this.getChild1();
if (child1.somethingComplex && someMoreComplexity) {
return true;
}
// some more things
return false;
}
}
We are using react & blaze on frontend and currently we only intend to migrate server side code to v3 of meteor as we don’t have client side updates, method stubs, etc.
Also Collection.findOne
is going to work in minimongo as it is so we don’t want to introduce findOneAsync
changes to frontend.
But above mentioned helpers are being used in both frontend & backend. If we change to async helpers, then frontend also have to change their callers to async and thus having to change to async to its caller’s caller and so on.
I also don’t want to have redundant helpers for both sync & async as if in case I have no choice, then I would change the frontend code to support async helpers anyways.
Do you guys have any trick that can help us avoid the frontend change?