Open
Description
If you make a simple async helper in conjuction with a meteor collection, during the sync of the collection, the helper is not updated.
I expect the helper to be refreshed once the collection is synced.
- Blaze:
3.0.1
- Meteor:
3.0.2
Here is a small code that you explain better the issue.
If you move up the line of find.fetch
before the async call it's working as expected.
Template.Home.onCreated(() => {
Tracker.autorun(async () => {
const user = await Meteor.userAsync();
Meteor.subscribe('projects', [user?.someProp]); // Help sync Project Meteor Collection
})
})
Template.Home.helpers({
// This is not working as expected
async someHelper(): Promise<string> {
const someAsyncCall = await myFunction();
if (someAsyncCall) {
const projects = Project.find({}).fetch();
console.log(projects.length) // Always 0
return 'yeah';
}
return ''
}
// This is working as expected
async someHelperWorking(): Promise<string> {
const someAsyncCall = await myFunction();
const projects = Project.find({}).fetch();
if (someAsyncCall) {
console.log(projects.length) // Always 10 (The amount subscribed)
return 'yeah';
}
return ''
}
})
Tell me if you need more information.
Metadata
Metadata
Assignees
Labels
No labels