Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Circular Reference

Expand Messages
  • Matt Sweeney
    Hi, You should be fine with that, but you could also make use of subscribe() s extra args to correct the scope, and avoid the self reference:
    Message 1 of 2 , Aug 28 5:25 PM
    • 0 Attachment
      Hi,

      You should be fine with that, but you could also make use of
      subscribe()'s extra args to correct the scope, and avoid the "self"
      reference:
      http://developer.yahoo.com/yui/docs/event/YAHOO.util.CustomEvent.html#subscribe

      Something like:

      var mot = new YAHOO.util.Motion(PrePort.Editor.OVERLAYID, atts, speed, YAHOO.util.Easing.easeOut);

      mot.onComplete.subscribe(
      function(){
      this.dialogShowing = false;
      this.internalHideOverlay();
      },
      this, // passed object
      true // scope to passed object
      );
      mot.animate();


      Matt

      prizeloop wrote:

      >First my code:
      >----------------------------
      >var self = this;
      >var mot = new YAHOO.util.Motion(PrePort.Editor.OVERLAYID, atts,
      >speed, YAHOO.util.Easing.easeOut);
      >
      >mot.onComplete.subscribe(
      > function(){
      > self.dialogShowing = false;
      > self.internalHideOverlay();
      > }
      >);
      >mot.animate();
      >----------------------------
      >
      >Am I creating any kind of long lasting circular reference with this
      >code by passing in the (self) variable? This bit of JavaScript is
      >inside an "Object" of mine and I need to set those "private"
      >variables. I just want to make sure I'm not creating some kind of
      >memory leak with some stupid references.
      >
      >
      >
      >
      >
      >
      >
      >Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.