I am using CompoundJS (an MVC for Express / NodeJS). To share code between controllers the Doc says that on controller1.js
I can share a method by using publish
method:
/***controller1.js***/
function sharedFunction () {...}
publish('sharedFunction', sharedFunction); //Sharing...
And in the controller2.js
I can access it by load
ing it and trying the use
method:
/***controller2.js***/
load('controller1'); // _controller siffix must be omitted
use('sharedFunction')
PROBLEM
This works great, however, I have a sharedFunction
that has params:
/***controller1.js***/
function sharedFunction (param1, param2) {...}
publish('sharedFunction', sharedFunction); //Sharing...
I have been reading the Docs, however I can't find how, or the syntax, to add this params on my use
method on controller1.js
. Where do I send these params?:
/***controller2.js***/
load('controller1'); // _controller siffix must be omitted
use('sharedFunction(params here?)', {params here?}) //where do I send the params?
Thank you very much!
Here's what I've done:
var sharedFunction = use('sharedFunction');
sharedFunction(param1, param2);