mgechev / aspect.js

JavaScript library for aspect-oriented programming using modern syntax.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript syntax extended classes

Markus-Harr opened this issue · comments

Hi,
thanks you, this library is great.
Unfortunately I've problems with logging of extended classes.

Depending where I use @wove() only methods off one class are logged (either foo or bar), but I don't get both logged together if constructor is executed. If both classes use wove decorator or only ClassA uses decorator => foo is logged. If only ClassB uses decorator => bar is logged.

file classB.js

import {Wove} from 'aspect.js';

@Wove()
export default class ClassB extends ClassA {

    constructor() {
        this.foo();
        this.bar();
    }

    bar() {
        ...
    }
    ...
}

file classA.js

import {Wove} from 'aspect.js';

@Wove()
export default ClassA {
    foo() {
        ...
    }
    ...
}

file logger.js

import {
  beforeMethod,
} from 'aspect.js';

export default class LoggerAspect {
  @beforeMethod({
      methodNamePattern: /.*/,
      classNamePattern: /.*/
  })
  beforeLogger(meta, ...args) {
      ...
  }
...
}

What is the correct syntax for this case?

Really good catch! I will push a fix in a bit.