samedi 18 avril 2015

Call method a JS file that includes my file

Parent file : Parent.js



exports.execute = function execute(request) {
var result = executeChild(request); // Will not work as the executeChild function is not in this file.
return "Hi!";
}


Child file : Child1.js



common = require('common');
execute = common.execute;
function executeChild(request) {
return "Hello1";
}


Child file : Child2.js



common = require('common');
execute = common.execute;
function executeChild(request) {
return "Hello2";
}


All the users of API call the execute method and they have no idea about the Parent child (OK may be its not a real Parent child relationship) relationship. How to make this function call (execute child) work.


NodeJs is used to execute this.


I would try to update the functions in the child files as a last resort and not before.


Aucun commentaire:

Enregistrer un commentaire