I’m writing a private meteor package that will be used with an open-source meteor project in a commercial product. Is it possible to use collection hooks (matb33:collection-hooks) in my private package?
MY current issue is the collection objects are defined in the open-source project as global variables and are out-of-scope within my private package. If I try and re-define them in my private package, I get errors thrown by the DDP package saying that some methods are already defined, e.g.,
Error: A method named '/<collectionName>/insert' is already defined.
Are there any hacks to access collections within packages?
Your collections should be visible in your package depending on if they were defined on client and server or both and if they were properly defined as global variables.
ReferenceError: Posts is not defined
at Router.map.route.path (packages/my:private-package/collections/posts.js:1:1)
I’ve defined my collection as a global variable in a folder (collection) accessible to both the client and the server. Is there anything else it might be?
The problem you are running into here is the fact that your package code executes prior to the application code. To fix this you can put any code that needs to run after the app loads inside of a Meteor.startup();