Skip to content

wrapMethod Meteor methods

I was looking into this presentation, building large meteor applications, and I like the idea of the wrapMethod(), but it seems like I can’t use it like on the example.

Here is my code.


  'EX.Accounts.Methods.updateProfileData' : function(userId, firstName, secondName) {
    check([firstName, secondName], [String]);
    Meteor.users.update(userId, {
      $set: {
        'profile.firstName': firstName,
        'profile.lastName': secondName,
        'profile.isRegisted': true

EX.Accounts.Methods.updateUserProfile =   EX.wrapMethod('EX.Accounts.Methods.updateProfileData');

But I got this error.

TypeError: Object # has no method ‘wrapMethod’

I’m missing something I know but just can’t find any information about this "wrapMethod"


Also try with

  updateUserProfile : EX.Accounts.Methods.updateProfileData

Which doesn’t return an error but I don’t see the method on the global namespace.

EX.Accounts.Methods is clear with no methods.


I think the developer created the method wrapMethod on his PB obejct. As you can see here there is nothing called wrapMethod in Meteor. I guess they wrote something like this:

PB.wrapMethod = function wrapMethod (meteorMethod) {
  return function wrappedMeteorMethod (/*arugments*/) {
    Meteor.apply(meteorMethod, arguments)

I think it’s kinda neat. Btw.: As you can see i like to name my anonymous functions. Makes debugging nicer.