Opened 7 years ago

Closed 7 years ago

#16626 closed defect (duplicate)

aspect.after behaves differently than documented

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

Description

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);
// ...
dojo.disconnect(handle);

is changed to:

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

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);
  /  ...
  handle.remove();
});

See the attached example.

Change History (1)

comment:1 Changed 7 years ago by Adam Peller

Resolution: duplicate
Status: newclosed

dup of #16627

Note: See TracTickets for help on using tickets.