Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment