A service service which wraps up Meteor.methods with AngularJS promises.
$meteor.call
has been deprecated in favor of of using regular Meteor Methods directly without any wrappers.Just call
Meteor.call
directly and work with the callback instead of the promise. Working with callback gives you the ability to close the subscription before it’s prepared, which you can’t do right now with the current Promise API.Here is an example for how to migrate:
Old code:
$meteor.call('invite', $scope.party._id, user._id).then(
function(data){
console.log('success inviting', data);
},
function(err){
console.log('failed', err);
}
);
New code:
Meteor.call('invite', $scope.party._id, user._id, function(error, result){
if (error) {
console.log('failed', err);
} else {
console.log('success inviting', data);
}
});
$meteor.call(name, methodArguments)
Param | Type | Details | Required |
---|---|---|---|
name | string | Name of method to invoke |
Yes |
methodArguments | any | Optional method arguments |
No |
promise | The promise solves successfully with the return value of the method or return reject with the error from the method |
$scope.invite = function(party, user){
$meteor.call('invite', party._id, user._id).then(
function(data){
// Handle success
console.log('success inviting', data.userId);
},
function(err){
// Handle error
console.log('failed', err);
}
);
};