0

I keep all common methods for server & client inside of /lib directory following the Meteor doc.

I do want keep some code separation for different utilities, so I have /lib/userUtils.js and /lib/messageUtils.js.

Inside of each of these classes. I want to have something like:

/lib/userUtils.js

UserUtils.findUser = function(user) {
  ...
}

/lib/messageUtils.js

MessageUtils.findMessage = function(id) {
  ...
}

This doesn't work in Meteor right now though. I would typically do function UserUtils() {} to statically define utility name first. But I just get UserUtils not found exception in my log.

k.chao.0424
  • 1,191
  • 10
  • 11
  • Seems like this boils down to a very common rookie issue, the mismanagement of dependencies and global variables. There is already a [couple](https://stackoverflow.com/questions/27509125/global-variables-in-meteor) [questions](https://stackoverflow.com/questions/26836390/how-can-i-access-constants-in-the-lib-constants-js-file-in-meteor) on this subject, check if they answer yours. – Kyll Jul 18 '15 at 23:19
  • 1
    @k.chao.0424 `UserUtils = {findUser: function(user) {...}}`? – David Weldon Jul 19 '15 at 00:08

0 Answers0