EventListeners

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

EventListeners

Jim Hunter

I recently modified my application so that all controls are pooled and re-used. It worked well for the most part, except that I tend to create anonymous functions for my event listeners. Once that object gets re-used, the old event listener is still attached to it. Is there a way to dump all event listeners easily? Or am I going to have to go back and create first class functions to be assigned to my events so that they can explicitly be removed? That is going to be a lot of work. I am hoping there is an easier way to do this.
 
Any suggestions would be appreciated. And naturally, my dealine for this is 2 days ago. :-)
 
Thanks,
Jim

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners

Derrell Lipman
On Tue, Aug 12, 2008 at 5:56 PM, Jim Hunter <[hidden email]> wrote:

I recently modified my application so that all controls are pooled and re-used. It worked well for the most part, except that I tend to create anonymous functions for my event listeners. Once that object gets re-used, the old event listener is still attached to it. Is there a way to dump all event listeners easily? Or am I going to have to go back and create first class functions to be assigned to my events so that they can explicitly be removed? That is going to be a lot of work. I am hoping there is an easier way to do this.
 
Any suggestions would be appreciated. And naturally, my dealine for this is 2 days ago. :-)

Hi Jim,

You're using 0.7, right?  There does not appear to be a function to do what you need, but it should be fairly easy to add one.  I think you're familiar with writing a mixin.  What I'd recommend is that you look at the method qx.core.Target.removeEventListener() and write a mixin that adds a removeAllEventListeners() method that you'd model on removeEventListener(), traversing the 'type' and 'key' nested objects.

Derrell



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners

Jim Hunter
Do you think this will work for annonymous functions?

On Tue, Aug 12, 2008 at 3:41 PM, Derrell Lipman <[hidden email]> wrote:
On Tue, Aug 12, 2008 at 5:56 PM, Jim Hunter <[hidden email]> wrote:

I recently modified my application so that all controls are pooled and re-used. It worked well for the most part, except that I tend to create anonymous functions for my event listeners. Once that object gets re-used, the old event listener is still attached to it. Is there a way to dump all event listeners easily? Or am I going to have to go back and create first class functions to be assigned to my events so that they can explicitly be removed? That is going to be a lot of work. I am hoping there is an easier way to do this.
 
Any suggestions would be appreciated. And naturally, my dealine for this is 2 days ago. :-)

Hi Jim,

You're using 0.7, right?  There does not appear to be a function to do what you need, but it should be fairly easy to add one.  I think you're familiar with writing a mixin.  What I'd recommend is that you look at the method qx.core.Target.removeEventListener() and write a mixin that adds a removeAllEventListeners() method that you'd model on removeEventListener(), traversing the 'type' and 'key' nested objects.

Derrell



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel




--
Jim Hunter

DAILY THOUGHT: SOME PEOPLE ARE LIKE SLINKIES - NOT REALLY GOOD
FOR ANYTHING BUT THEY BRING A SMILE TO YOUR FACE WHEN PUSHED DOWN THE STAIRS

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners

Derrell Lipman


On Tue, Aug 12, 2008 at 7:00 PM, Jim Hunter <[hidden email]> wrote:
Do you think this will work for annonymous functions?

Yes.  You're going to iterate over all of the objects there are, so it'll find the anonymous functions as well.

Derrell
 


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners

Fabian Jakobs
Administrator
Hi Jim,

It may be even easier if you just reset the __listeners field:

removeAllListeners : function()
{
    this._disposeObjectDeep("__listeners", 2);
    this.__listeners = {};
}

Put this in a mixin and add it to qx.core.Target.

This will work with anonymous functions as well.

Best Fabian

>
>
> On Tue, Aug 12, 2008 at 7:00 PM, Jim Hunter <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Do you think this will work for annonymous functions?
>
>
> Yes.  You're going to iterate over all of the objects there are, so
> it'll find the anonymous functions as well.
>
> Derrell
>  
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ------------------------------------------------------------------------
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>  


--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstra├če 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: EventListeners

Jim Hunter
Sometimes the answer is so simple you overlook it. I was drilling into __listeners and trying to call removeEventListener on it's members but the short amount of time I spent on it I was not having success. This sounds like a very simply and efficient way to solfe the problem.

Thanks!

Jim


On Thu, Aug 14, 2008 at 2:11 AM, Fabian Jakobs <[hidden email]> wrote:
Hi Jim,

It may be even easier if you just reset the __listeners field:

removeAllListeners : function()
{
   this._disposeObjectDeep("__listeners", 2);
   this.__listeners = {};
}

Put this in a mixin and add it to qx.core.Target.

This will work with anonymous functions as well.

Best Fabian
>
>
> On Tue, Aug 12, 2008 at 7:00 PM, Jim Hunter <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Do you think this will work for annonymous functions?
>
>
> Yes.  You're going to iterate over all of the objects there are, so
> it'll find the anonymous functions as well.
>
> Derrell
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ------------------------------------------------------------------------
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>


--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstra├če 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



--
Jim Hunter

DAILY THOUGHT: SOME PEOPLE ARE LIKE SLINKIES - NOT REALLY GOOD
FOR ANYTHING BUT THEY BRING A SMILE TO YOUR FACE WHEN PUSHED DOWN THE STAIRS

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel