I\'m performing a database count through a server method. Users can select how they want the count to be performed and then invoke the method.
My problem is that the cou
Cancelling an already-made method call to server from client is not possible.
But if your method are called multiple times in a short interval, and you only care about the last call's result. You could use debounce to delay execution for some times. This will help reduce unnecessary calls to server.
More of a work around, but if you had a reactive variable (could be an entry in the DB) that is a status of the method, and in the method itself, you check for that flag every chance you get for the status.
{
_id: "some id for the method", running: true
}
Pseudocode for method
Meteor.methods({
method: (_id) => {
status = getStatusForId(_id);
while(status) {
status = getStatusForId(_id);
}
}
});
Then to stop it, you just update that flag to be false and the method will stop as soon as it can.