Opened 10 years ago
Closed 9 years ago
#14129 closed defect (invalid)
aspect.before bypasses aspect.around
Reported by: | Marcel Lucas | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | tbd |
Component: | Events | Version: | 1.7.0b1 |
Keywords: | AOP aspect before around | Cc: | |
Blocked By: | Blocking: |
Description
From http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/
The “around” advice will “eat” all previously attached “before” and “after” advices changing the order of their execution. We cannot guarantee anymore that “before” advices run before all “around” advices, and so on.
The current implementation kind of handles “around”/ parallel to “before”|“after” no matter in which order they are chained (means “before” chain is executed, “around” chain is executed right afterwards, followed by “after” chain)
require(["dojo/aspect"],function(aspect){ var context = {func:function(){console.log("YOU DONT WANNA SEE THIS")}}; aspect.after (context, "func", function(){console.log("DONE")}); aspect.before(context, "func", function(){console.log("LET ME SHOW YOU SOMETHING...")}); aspect.before(context, "func", function(){console.log("HEY BUD!")}); aspect.around(context, "func", function(){return function(){console.log("... I HAVE NOTHING TO SHOW")}}); context .func(); }); //outputs: //HEY BUD! //LET ME SHOW YOU SOMETHING... //... I HAVE NOTHING TO SHOW //DONE //expected: //... I HAVE NOTHING TO SHOW
I'm working "around" this problem by using aspect.around only (respectively the context-patched version #13992)
Change History (4)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Milestone: | 1.7.1 → tbd |
---|
comment:3 Changed 10 years ago by
Thanks for that quick response.
For me it was the intended behavior that arounds eat all other advices. The ticket can be closed as the current implementatin is definitely intended to be a problem solving feature - which I interpreted as an error.
I just wish to see a clear note to this behavior in the upcoming documentation.
Regards
comment:4 Changed 9 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
The blog post talks about around advice eating other advice as a problem. Why would we want to introduce this problem?