You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Frank Dahmen <fr...@dahmenia.de> on 2016/11/25 14:25:35 UTC

will event handlers in mxml be removed automatically?

Hi,
e.g.

<s:View creationComplete="init()">
     <s:Button click="do() "/>
</s:View>

when i call navigator.popView()
will the 2 eventhandlers be removed so the view can be gc'd ?

thanks



Re: will event handlers in mxml be removed automatically?

Posted by Alex Harui <ah...@adobe.com>.

On 11/25/16, 7:39 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:

>great, thanks
>
>but when added in AS then I always have to remove them manually, right?

Only if you are listening to something outside of the class that will
block GC and in that case, you can use weak references.

HTH,
-Alex


Re: will event handlers in mxml be removed automatically?

Posted by Frank Dahmen <fr...@dahmenia.de>.
ok, thanks


Am 25.11.2016 um 16:41 schrieb Kyle McKnight:
> It's always good practice to remove them yes. You can also look into weakly
> referenced listeners, but it's still better to remove them yourself
>
>
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
>
> On Fri, Nov 25, 2016 at 10:39 AM, Frank Dahmen <fr...@dahmenia.de> wrote:
>
>> great, thanks
>>
>> but when added in AS then I always have to remove them manually, right?
>>
>> e.g.:
>>
>> private function do():void{
>>       otherBtn.addEventListener(.....);
>> }
>>
>> when is this done best in a view?
>> here:
>>
>> <s:View viewDeactivate="functionToRemoveAllASListeners()">
>>
>> ?
>>
>>
>>
>>
>> Am 25.11.2016 um 16:27 schrieb Alex Harui:
>>
>>> On 11/25/16, 6:25 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:
>>>
>>> Hi,
>>>> e.g.
>>>>
>>>> <s:View creationComplete="init()">
>>>>       <s:Button click="do() "/>
>>>> </s:View>
>>>>
>>>> when i call navigator.popView()
>>>> will the 2 eventhandlers be removed so the view can be gc'd ?
>>>>
>>> Assuming init() and do() are defined in the same MXML file and do not
>>> reference things outside the MXML file, there is no need to remove the
>>> handlers to enable GC.
>>>
>>> HTH,
>>> -Alex
>>>
>>>


Re: will event handlers in mxml be removed automatically?

Posted by Kyle McKnight <ka...@gmail.com>.
It's always good practice to remove them yes. You can also look into weakly
referenced listeners, but it's still better to remove them yourself


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Fri, Nov 25, 2016 at 10:39 AM, Frank Dahmen <fr...@dahmenia.de> wrote:

> great, thanks
>
> but when added in AS then I always have to remove them manually, right?
>
> e.g.:
>
> private function do():void{
>      otherBtn.addEventListener(.....);
> }
>
> when is this done best in a view?
> here:
>
> <s:View viewDeactivate="functionToRemoveAllASListeners()">
>
> ?
>
>
>
>
> Am 25.11.2016 um 16:27 schrieb Alex Harui:
>
>>
>> On 11/25/16, 6:25 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:
>>
>> Hi,
>>> e.g.
>>>
>>> <s:View creationComplete="init()">
>>>      <s:Button click="do() "/>
>>> </s:View>
>>>
>>> when i call navigator.popView()
>>> will the 2 eventhandlers be removed so the view can be gc'd ?
>>>
>> Assuming init() and do() are defined in the same MXML file and do not
>> reference things outside the MXML file, there is no need to remove the
>> handlers to enable GC.
>>
>> HTH,
>> -Alex
>>
>>
>

Re: will event handlers in mxml be removed automatically?

Posted by Frank Dahmen <fr...@dahmenia.de>.
great, thanks

but when added in AS then I always have to remove them manually, right?

e.g.:

private function do():void{
      otherBtn.addEventListener(.....);
}

when is this done best in a view?
here:

<s:View viewDeactivate="functionToRemoveAllASListeners()">

?




Am 25.11.2016 um 16:27 schrieb Alex Harui:
>
> On 11/25/16, 6:25 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:
>
>> Hi,
>> e.g.
>>
>> <s:View creationComplete="init()">
>>      <s:Button click="do() "/>
>> </s:View>
>>
>> when i call navigator.popView()
>> will the 2 eventhandlers be removed so the view can be gc'd ?
> Assuming init() and do() are defined in the same MXML file and do not
> reference things outside the MXML file, there is no need to remove the
> handlers to enable GC.
>
> HTH,
> -Alex
>


Re: will event handlers in mxml be removed automatically?

Posted by Kyle McKnight <ka...@gmail.com>.
I know that you can not remove them manually by calling
removeEventListener. There is documentation somewhere stating that. I do
not know if they are removed internally by the framework


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Fri, Nov 25, 2016 at 10:27 AM, Alex Harui <ah...@adobe.com> wrote:

>
>
> On 11/25/16, 6:25 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:
>
> >Hi,
> >e.g.
> >
> ><s:View creationComplete="init()">
> >     <s:Button click="do() "/>
> ></s:View>
> >
> >when i call navigator.popView()
> >will the 2 eventhandlers be removed so the view can be gc'd ?
>
> Assuming init() and do() are defined in the same MXML file and do not
> reference things outside the MXML file, there is no need to remove the
> handlers to enable GC.
>
> HTH,
> -Alex
>
>

Re: will event handlers in mxml be removed automatically?

Posted by Alex Harui <ah...@adobe.com>.

On 11/25/16, 6:25 AM, "Frank Dahmen" <fr...@dahmenia.de> wrote:

>Hi,
>e.g.
>
><s:View creationComplete="init()">
>     <s:Button click="do() "/>
></s:View>
>
>when i call navigator.popView()
>will the 2 eventhandlers be removed so the view can be gc'd ?

Assuming init() and do() are defined in the same MXML file and do not
reference things outside the MXML file, there is no need to remove the
handlers to enable GC.

HTH,
-Alex