cujojs/meld

Does meld.js support AOP on functions?

Closed this issue · 1 comments

AOP advice seems not working on functions below,

meld = require('meld')

function fn() {}
meld.after(fn, function() {console.log('fn is called.')})
fn()

Hey @fansgit. Meld operates at runtime by wrapping functions and replacing methods (i.e. by overwriting method properties of objects). Without doing AST or source code transformations at "compile" time, it's impossible to mutate a pure function, as shown in your example.

Meld supports "advising" pure functions by wrapping and returning a new function. See the usage example in the docs behind that link for more info. Hope that helps!