Skip to content

Instantly share code, notes, and snippets.

@k1r0s
Created April 16, 2018 09:26
Show Gist options
  • Select an option

  • Save k1r0s/fdefdcd7753dc3de53a8cc37422c7ae9 to your computer and use it in GitHub Desktop.

Select an option

Save k1r0s/fdefdcd7753dc3de53a8cc37422c7ae9 to your computer and use it in GitHub Desktop.
const { beforeMethod } = require("kaop-ts");
const Log = meta => {
console.log(meta.key)
console.log(meta.scope)
console.log(meta.args)
}
function applyToAll(advice) {
return function applyAll(target) {
const wove = beforeMethod(advice);
for (let key in target.prototype) {
Object.defineProperty(target.prototype, key,
wove(target, key, Object.getOwnPropertyDescriptor(target.prototype, key)));
}
}
}
const track = applyToAll(Log)
@track
class YourService {
method1(num, str) {
}
method2(num, str) {
}
method3(num, str) {
}
method4(num, str) {
}
}
const b = new YourService;
const a = new YourService;
b.method1(1, 123)
a.method2("asdas", 131231)
a.method4({asd: 1}, 131231)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment