Jump to content

Signal.addOnce arguments behaving funny


QLNEO
 Share

Recommended Posts

Please take a look at the two following pieces of code:

// Form 1
paddle.events.onDragStart.addOnce(ball.setMovement, ball);

// Form 2
paddle.events.onDragStart.addOnce(function() {
   this.setMovement();
}, ball);

Technically these two should be the same. But, for some reason, the first variant isn't quite working according to the plan. In fact, ball is being sent as an argument to .setMovement() instead of being the context, as the docs make me think it should be. The second form works as expected, ball being treated as this.

Is this a bug, an example of badly explained documentation or I'm missing something obvious?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...