mgechev/aspect.js

JavaScript syntax extended classes

Markus-Harr opened this issue · 2 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.