Meteor common logic code


#1

thanks for Seeing and Answering this issue!(My English is poor~)

In my project,I have a puzzle:
When user register or buy somethings,we’ll send a system message;
so,methods.js:userRegister() or payOrder() need to invoke sendMessage();
but,which fit file or best practice to write sendMessage code


#2

If this is on server as a method you can just use
Meteor.call('name.of.the.method', 'message');


#3

Meteor.call is correct if userRegister() or payOrder() are executed only at the client side.
If they are executed only at the server side, write a normal function call to sendMessage().
If they are called on both server and client side, use Meteor.isServer and write a normal function call to sendMessage().