Open antonioaltamura opened 8 years ago
Perhaps you should instead consider Dependency Injection. This is when you write your modules as a function (or "factory") that encompasses the module's methods, and that factory accepts the dependencies (views in that example) as it's arguments.
Here are a couple simple examples: https://blog.risingstack.com/fundamental-node-js-design-patterns/#dependencyinjection http://stackoverflow.com/a/36771139
'views' in your question is an object like any other that can be injected into your modules, or assigned to some application object that is passed to all your modules.
Hi, it would be very helpful if the module 'propagates' the variables defined in it in the node.js environment. Il'l explain better: in your base example you wrote
but it would be VERY helpful if 'views' would be visible in all the other node.js scripts (obiouvsly requiring "requirefrom"). What do you think?