Opened 9 years ago

Closed 9 years ago

#16627 closed defect (fixed)

aspect.after behaves differently than documented

Reported by: dmitry.pikhulya Owned by: Kris Zyp
Priority: undecided Milestone: 1.9
Component: Events Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:


There is either a migration documentation bug, or an actual bug in the code.

The Dojo 1.x to 2.0 migration guide mentions that the code like this

var handle = dojo.connect(myInstance, "execute", callback);
// ...

is changed to:

require(["dojo/aspect"], function(aspect){
  var handle = aspect.after(myInstance, "execute", callback);
  /  ...

and mentions that "...callback() should not return a value..."

but such a replacement of dojo.connect(...) to aspect.after(...) is actually different than the original in two ways, unless you add pass true in the third receiveArguments argument of aspect.after method:

  • myInstance.execute will return undefined when callback does not return a value as recommended in the documentation;
  • The callback function will receive a different set of parameters if the recommended replacement is done as is.

The proper replacement that works as expected in these cases is:

require(["dojo/aspect"], function(aspect){
  var handle = aspect.after(myInstance, "execute", callback, true);
  /  ...

See the attached example.

Attachments (1)

dojo-connect-and-aspect-after.html (2.1 KB) - added by dmitry.pikhulya 9 years ago.

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by dmitry.pikhulya

comment:1 Changed 9 years ago by Kris Zyp

Milestone: tbd1.9
Resolution: fixed
Status: newclosed

Updated the live docs as described in the ticket.

Note: See TracTickets for help on using tickets.