You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2020/10/20 02:13:20 UTC

Added helper function on Bead.as to make beads cleaner

Hi,

As I'm slowly moving forward on Royale, I'm adapting my code more Royale
way.

In the old Flex way, the controls (TextInput and so on) end up with a lot
of bloatware to face many possible functionalities, my own controls of the
last layer have exactly the same issue.
For example, I have several LOV controls and each other have many, many
lines of codes for specific scenarios.

I'm started now with Beads on my own controls (strands).
The goal is to end up with very small components and many beads.

So I'm extending from Bead and using the helper function listenOnStrand
(usefully) but it's missing the opposite, so I added it pull a request:
https://github.com/apache/royale-asjs/pull/923

Re: Added helper function on Bead.as to make beads cleaner

Posted by Carlos Rovira <ca...@apache.org>.
Hi Hugo,

Many thanks for discussing the issue. Is good for the project that we talk
about this kind of changes as we go "down to core", since it will impact
the rest of sub libraries and frameworks.

I must admit that I found the lack of an opposite function to
"listenOnStand". I think I wanted to use it at least 3-4 times. so for me
it will be ok.

But would like to know what others think about it so we get consensus on
things like this.

Thanks

Carlos



El mar., 20 oct. 2020 a las 10:20, hferreira (<hf...@gmail.com>)
escribió:

> Hi,
>
> What do you thing about adding this to Bead.as ?
>
> /**
>      * Helper function to remove event listener without the need for
> casting
>      * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
>      */
>     protected function
>
> unlistenOnStrand(eventType:String,handler:Function,capture:Boolean=false):void
>     {
>       (_strand as IEventDispatcher).removeEventListener(eventType, handler,
> capture);
>     }
>
> I know that Bead.as should be keep simple but if we have listenOnStrand,
> shouldn't we also have unlistenOnStrand ?
>
>
>
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/
>


-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Re: Added helper function on Bead.as to make beads cleaner

Posted by Carlos Rovira <ca...@apache.org>.
Hi Yishay,

yes we'll do the global function.

About a case, for example listening to "initComplete" and then in the
handler want to remove the listener.
That and other similar cases are very normal if you want to ensure you
don't leave listeners hanging and by that way instances not garbage
collected. I found that situation very often, so normal that Hugo caught
and asked it.

Anyway I think we have consensus on the resolution :)

El mar., 20 oct. 2020 a las 19:04, Yishay Weiss (<yi...@hotmail.com>)
escribió:

> Most of the times I just implement IBead rather than extending Bead.as and
> I’m not sure how much it is being used, but it should probably be kept
> small. I personally have not needed unlistenOnStrand. Hugo & Carlos, when
> was this necessary for you guys?
>
> > if we have listenOnStrand, shouldn't we also have unlistenOnStrand ?
>
> Not necessarily. I think we should provide the minimal interface that is
> good enough for the most common use cases.
>
> As I see it, a solution that does not compromise PAYG is to create
> function class unlistenOnStrand which can be imported if need be.
>
> From: hferreira<ma...@gmail.com>
> Sent: Tuesday, October 20, 2020 11:20 AM
> To: dev@royale.apache.org<ma...@royale.apache.org>
> Subject: Re: Added helper function on Bead.as to make beads cleaner
>
> Hi,
>
> What do you thing about adding this to Bead.as ?
>
> /**
>      * Helper function to remove event listener without the need for
> casting
>      * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
>      */
>     protected function
>
> unlistenOnStrand(eventType:String,handler:Function,capture:Boolean=false):void
>     {
>       (_strand as IEventDispatcher).removeEventListener(eventType, handler,
> capture);
>     }
>
> I know that Bead.as should be keep simple but if we have listenOnStrand,
> shouldn't we also have unlistenOnStrand ?
>
>
>
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/
>
>

-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira

Re: Added helper function on Bead.as to make beads cleaner

Posted by Hugo Ferreira <hf...@gmail.com>.
Yishay Weiss,

I have very, very complex controls on my Flex application because these
controls must be compatible with many use cases.
I see now the valuable on composition approach.
I end up with an insane small version on Royale that will require many
beads that each one will use events that I want to make sure to remove the
listeners.
As I saw a helper for add listeners, I thought that a remove also makes
sense but it's not an issue for me. I can remove it the standard way :)

Yishay Weiss <yi...@hotmail.com> escreveu no dia terça, 20/10/2020
à(s) 18:04:

> Most of the times I just implement IBead rather than extending Bead.as and
> I’m not sure how much it is being used, but it should probably be kept
> small. I personally have not needed unlistenOnStrand. Hugo & Carlos, when
> was this necessary for you guys?
>
> > if we have listenOnStrand, shouldn't we also have unlistenOnStrand ?
>
> Not necessarily. I think we should provide the minimal interface that is
> good enough for the most common use cases.
>
> As I see it, a solution that does not compromise PAYG is to create
> function class unlistenOnStrand which can be imported if need be.
>
> From: hferreira<ma...@gmail.com>
> Sent: Tuesday, October 20, 2020 11:20 AM
> To: dev@royale.apache.org<ma...@royale.apache.org>
> Subject: Re: Added helper function on Bead.as to make beads cleaner
>
> Hi,
>
> What do you thing about adding this to Bead.as ?
>
> /**
>      * Helper function to remove event listener without the need for
> casting
>      * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
>      */
>     protected function
>
> unlistenOnStrand(eventType:String,handler:Function,capture:Boolean=false):void
>     {
>       (_strand as IEventDispatcher).removeEventListener(eventType, handler,
> capture);
>     }
>
> I know that Bead.as should be keep simple but if we have listenOnStrand,
> shouldn't we also have unlistenOnStrand ?
>
>
>
> --
> Sent from: http://apache-royale-development.20373.n8.nabble.com/
>
>

RE: Added helper function on Bead.as to make beads cleaner

Posted by Yishay Weiss <yi...@hotmail.com>.
Most of the times I just implement IBead rather than extending Bead.as and I’m not sure how much it is being used, but it should probably be kept small. I personally have not needed unlistenOnStrand. Hugo & Carlos, when was this necessary for you guys?

> if we have listenOnStrand, shouldn't we also have unlistenOnStrand ?

Not necessarily. I think we should provide the minimal interface that is good enough for the most common use cases.

As I see it, a solution that does not compromise PAYG is to create function class unlistenOnStrand which can be imported if need be.

From: hferreira<ma...@gmail.com>
Sent: Tuesday, October 20, 2020 11:20 AM
To: dev@royale.apache.org<ma...@royale.apache.org>
Subject: Re: Added helper function on Bead.as to make beads cleaner

Hi,

What do you thing about adding this to Bead.as ?

/**
     * Helper function to remove event listener without the need for casting
     * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
     */
    protected function
unlistenOnStrand(eventType:String,handler:Function,capture:Boolean=false):void
    {
      (_strand as IEventDispatcher).removeEventListener(eventType, handler,
capture);
    }

I know that Bead.as should be keep simple but if we have listenOnStrand,
shouldn't we also have unlistenOnStrand ?



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/


Re: Added helper function on Bead.as to make beads cleaner

Posted by hferreira <hf...@gmail.com>.
Hi,

What do you thing about adding this to Bead.as ?

/**
     * Helper function to remove event listener without the need for casting
     * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
     */
    protected function
unlistenOnStrand(eventType:String,handler:Function,capture:Boolean=false):void
    {
      (_strand as IEventDispatcher).removeEventListener(eventType, handler,
capture);
    }

I know that Bead.as should be keep simple but if we have listenOnStrand,
shouldn't we also have unlistenOnStrand ?



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/