Reputation: 43
I know Meteor does client-side caching of the database for better effective performance. In the client-side Meteor method call, is there any way to know when the server-side database operation actually finishes (or if it actually failed)? Are there events I can hook into to get notification when the full remote procedure call finishes? Is there some way to use subscribe()
to know when this particular call "really" finishes?
For example, from the simple-todos tutorial, is there a way to get notification when the server-side deleteTask implementation is completely done (i.e. the server-side database has been updated successfully)?
Template.task.events({
"click .delete": function () {
Meteor.call("deleteTask", this._id);
},
});
I know Meteor intentionally hides the server processing delay, but I'm curious about the net operation performance of the Meteor methods I'm writing.
Upvotes: 2
Views: 78
Reputation: 64312
Just include a callback with your Meteor.call. The callback will be run after the server has completed processing the request.
Template.task.events({
'click .delete': function () {
Meteor.call('deleteTask', this._id, function(err, result){
if (err){
// an error was thrown
} else {
// everything worked!
}
})
}
});
Upvotes: 2