Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to completely handle invocation & return value in around advice (like AspectJ does) #75

Closed
matthewadams opened this issue Nov 14, 2018 · 0 comments

Comments

@matthewadams
Copy link
Collaborator

It is impossible for the user of aspect.js to completely handle around advice and prevent the advice from executing twice. Note comments in code block from master lib/src/advices/sync_advices.ts below:

export class AroundAdvice extends Advice {                                      // line 20
  wove(target: Function, metadata: Metadata) {
    this.advice.bind(this.context, metadata).apply(null, metadata.method.args); // calls advice, user can set metadata.method.proceed to false
    this.invoke(target, metadata);                                              // if metadata.method.proceed is false, invocation is skipped as it should be
    this.advice.bind(this.context, metadata).apply(null, metadata.method.args); // if metadata.method.proceed is false, advice is _still_ called -- this is inconvenient!
    return metadata.method.result;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant