I have hasCompleted
function that returns true
or false
which is in the server file file:
Smaples.helpers({
hasCompleted(userId) {
// …
switch (this.frequency) {
case Frequency.ONE_TIME:{
return measures.fetch().every(measure => {
console.log(
'measure.hasCompleted(userId)', // true
measure.hasCompleted(userId),
);
measure.hasCompleted(userId);
});
}
}
// …
},
})
But when it comes to the client side the above function returns false
.
On the client side using useTracker
:
const hasCompleted = useTracker(
() => sample.hasCompleted(Meteor.myFunctions.getCurrentUserId()),
);
console.log(
'survey.hasCompleted(Meteor.myFunctions.getCurrentUserId())', // false
survey.hasCompleted(Meteor.myFunctions.getCurrentUserId()),
);
console.log('hasCompleted', hasCompleted); // false
The way I access helpers from the client side, is this wrong?
Attempts
inside hasCompleted
I manually return true
and the console shows true
:
Smaples.helpers({
hasCompleted(userId) {
// …
switch (this.frequency) {
case Frequency.ONE_TIME:{
return true; // changed
}
// …
},
})
Also, I thought if
console.log(measure.hasCompleted(userId))
after returning it could be changed, but
console.log(measure.hasCompleted(userId))
still returns true
:
Smaples.helpers({
hasCompleted(userId) {
// …
switch (this.frequency) {
case Frequency.ONE_TIME:{
return measures.fetch().every(measure => {
measure.hasCompleted(userId);
console.log(
'measure.hasCompleted(userId)', // true
measure.hasCompleted(userId),
);
});
}
}
// …
},
})
What am I doing wrong?