When I try to implement AOP using meld.js (from cujojs) for standalone javascript functions, it is NOT executing Advice. I have been trying with the below code.
var meld = require("meld")
function afterReturn(returnValue){
console.log(returnValue);
}
function test(x,y) {
console.log(x);
console.log(y);
return x+y;
}
var remover = meld.afterReturning(test, afterReturn);
test(5,6);
:
5 AND 6
But, when I wrap the function inside some object (myo), it works. I don't want to wrap functions inside any object.
var meld = require("meld")
function x(returnValue) {
console.log(returnValue);
}
var myo = {
test : function(x,y) {
console.log(x);
console.log(y);
return x+y;
}
}
var remover = meld.afterReturning(myo,'test', x);
myo.test(5,6);
:
5, 6 AND 11
Could you please correct me where I am doing wrong.