Remove or redefine defined meteor methods?


#1

Hi, sorry if this is a stupid noob question, but I’m wondering if it’s possible to remove or redefine an already defined meteor method? Something like the following:

Meteor.methods({
    "doFoo": function() {
        // do something here
    }
});

// somewhere else in code, something like: 
Meteor.removeMethod('doFoo');

#2

Necromancing your question :slight_smile: I needed to do this for a password rotation scheme.

Here’s what I came up with:

// First, we delete the existing handler
delete Meteor.server.method_handlers.changePassword;
delete Meteor.default_server.method_handlers.changePassword;

// Next we redefine the method.
Meteor.methods({changePassword: function (oldPassword, newPassword) {
    ...
  }
});

Ugly, but seems to work.


#3

This is what I used in Reval https://github.com/qualialabs/reval/blob/master/packages/qualia_reval/server/plugins/methods.js#L15


#4

Hey @veered, interesting!

Did you need to modify the client to work with the new version of the method?

Our intent is to replace the method server side with the same parameters…


#5

Only if the meteor method is also defined on the client; this is usually not the case