You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by yishayw <yi...@hotmail.com> on 2017/06/20 06:10:32 UTC
Re: [FlexJS] How Binding works?
We have an mxml component where
[Bindable]public var locStrings:IUIStrings = LocaleManager.localeStrings;
...
<js:beads>
<js:ContainerDataBinding/>
</js:beads>
...
<js:TextButton text="{locStrings.PURCHASED}"/>
LocaleManager is declared thus:
[Bindable]
public class LocaleManager
and it has:
public static function get
localeStrings():IUIStrings
where IUIString is declared thus:
[Bindable]public interface IUIStrings
and its implementation is declares like this:
[Bindable]public class DefaultStrings implements
IUIStrings
Can anyone explain why I'm seeing this?
Data binding will not be able to detect assignments
to 'PURCHASED'.
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-Binding-works-tp57096p62481.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
RE: [FlexJS] How Binding works?
Posted by Yishay Weiss <yi...@hotmail.com>.
It’s more to let the compiler know the implementations are bindable. I don’t expect them to automatically become bindable.
From: piotrz<ma...@gmail.com>
Sent: Tuesday, June 20, 2017 9:52 AM
To: dev@flex.apache.org<ma...@flex.apache.org>
Subject: RE: [FlexJS] How Binding works?
Hi Yishay,
Actaully what is the purpose to have Bindable in the interface ? I have
never seen such things in old Flex.
You are expecting that once you implement such interface you will have
[Bindable] inherited ?
Piotr
-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-Binding-works-tp57096p62486.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
RE: [FlexJS] How Binding works?
Posted by piotrz <pi...@gmail.com>.
Hi Yishay,
Actaully what is the purpose to have Bindable in the interface ? I have
never seen such things in old Flex.
You are expecting that once you implement such interface you will have
[Bindable] inherited ?
Piotr
-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-Binding-works-tp57096p62486.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How Binding works?
Posted by yishayw <yi...@hotmail.com>.
In this [1] app, referencing the interface [2] results in a warning, but
referencing the implementer [3] does not.
So it looks like the problem is with bindable interfaces only.
Thanks.
[1] https://paste.apache.org/JmIV
[2] https://paste.apache.org/zxSB
[3] https://paste.apache.org/Qko2
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-Binding-works-tp57096p62492.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How Binding works?
Posted by Alex Harui <ah...@adobe.com.INVALID>.
It might be that the compiler is not handling [Bindable] on interfaces.
I'm pretty sure I've seen it work on classes. If you can run a quick test
to prove that, then that should be fixed in the compiler.
But using [Bindable] sets up change events on the public properties in the
class and if the value of the property is effectively a constant, then you
can make your app smaller and faster by telling the subsystem that some
property won't be dispatching change events.
I don't know if defining the properties as "const" instead of "var" would
work or not. Might be worth a try.
Some day in the future, I hope we find time to optimize binding to
constants. And in this case, binding for localization. If your app does
not support changing locales at runtime (it picks up locale at startup and
assumes it never changes), there is probably better code that could be
generated.
Thanks,
-Alex
On 6/20/17, 12:09 AM, "Yishay Weiss" <yi...@hotmail.com> wrote:
>I agree it’s wasteful, but there’s a lot of old code that we’re porting
>that uses this as a shortcut. I’ve changed all interface get definitions
>to be prefixed with [Bindable("__NoChangeEvent__")] and the compiler now
>seems happy. It should probably be enough to add it the interface
>declaration instead.
>
>If I were to rewrite the code what syntax would you suggest instead of
><Label text="{locStrings.SEARCH}”/> ?
>
>From: Alex Harui<ma...@adobe.com.INVALID>
>Sent: Tuesday, June 20, 2017 9:57 AM
>To: dev@flex.apache.org<ma...@flex.apache.org>
>Subject: Re: [FlexJS] How Binding works?
>
>I believe the warning was that the value of PURCHASED could change. The
>Bindable subsystem does not know that the getter will always return the
>same string literal. If other stuff could change, but didn't specify a
>change event, I would hope the compiler would warn about that part of the
>bindable expression.
>
>IMO, one should never use plain [Bindable] with getters and setters. That
>just wraps the getter/setter in another getter/setter with change event
>detection. That adds up eventually both in code size and runtime.
>Suddenly you are making two function calls instead of one to access the
>underlying value.
>
>You could use [Bindable("__NoChangeEvent__")] if you know a value doesn't
>change but isn't a const. You probably don't want to add listeners for
>when PURCHASED changes, just when the current location manager changes.
>
>Of course, I could be wrong.
>
>-Alex
>
>
>
>On 6/19/17, 11:28 PM, "yishayw" <yi...@hotmail.com> wrote:
>
>>It looks like changing the definitions of the interface and the class to
>>
>> [Bindable]function get PURCHASED():String;
>>and
>> [Bindable]public function get PURCHASED():String { return
>>"PURCHASED"; }
>>
>>worked.
>>
>>So is it a bug that declaring the class and the interface as bindable was
>>not enough?
>>
>>
>>
>>
>>
>>--
>>View this message in context:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fl
>>e
>>x-development.2333347.n4.nabble.com%2FFlexJS-How-Binding-works-tp57096p62
>>4
>>85.html&data=02%7C01%7C%7Cdeee45fa75c74c1828da08d4b7a7f7f2%7Cfa7b1b5a7b34
>>4
>>38794aed2c178decee1%7C0%7C0%7C636335379433525746&sdata=uK6hxHRAC%2BkVi8%2
>>B
>>igjlqgOKAypeFlS1EwLbZ6qNniDk%3D&reserved=0
>>Sent from the Apache Flex Development mailing list archive at Nabble.com.
>
RE: [FlexJS] How Binding works?
Posted by Yishay Weiss <yi...@hotmail.com>.
I agree it’s wasteful, but there’s a lot of old code that we’re porting that uses this as a shortcut. I’ve changed all interface get definitions to be prefixed with [Bindable("__NoChangeEvent__")] and the compiler now seems happy. It should probably be enough to add it the interface declaration instead.
If I were to rewrite the code what syntax would you suggest instead of <Label text="{locStrings.SEARCH}”/> ?
From: Alex Harui<ma...@adobe.com.INVALID>
Sent: Tuesday, June 20, 2017 9:57 AM
To: dev@flex.apache.org<ma...@flex.apache.org>
Subject: Re: [FlexJS] How Binding works?
I believe the warning was that the value of PURCHASED could change. The
Bindable subsystem does not know that the getter will always return the
same string literal. If other stuff could change, but didn't specify a
change event, I would hope the compiler would warn about that part of the
bindable expression.
IMO, one should never use plain [Bindable] with getters and setters. That
just wraps the getter/setter in another getter/setter with change event
detection. That adds up eventually both in code size and runtime.
Suddenly you are making two function calls instead of one to access the
underlying value.
You could use [Bindable("__NoChangeEvent__")] if you know a value doesn't
change but isn't a const. You probably don't want to add listeners for
when PURCHASED changes, just when the current location manager changes.
Of course, I could be wrong.
-Alex
On 6/19/17, 11:28 PM, "yishayw" <yi...@hotmail.com> wrote:
>It looks like changing the definitions of the interface and the class to
>
> [Bindable]function get PURCHASED():String;
>and
> [Bindable]public function get PURCHASED():String { return
>"PURCHASED"; }
>
>worked.
>
>So is it a bug that declaring the class and the interface as bindable was
>not enough?
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-How-Binding-works-tp57096p624
>85.html&data=02%7C01%7C%7Cdeee45fa75c74c1828da08d4b7a7f7f2%7Cfa7b1b5a7b344
>38794aed2c178decee1%7C0%7C0%7C636335379433525746&sdata=uK6hxHRAC%2BkVi8%2B
>igjlqgOKAypeFlS1EwLbZ6qNniDk%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How Binding works?
Posted by Alex Harui <ah...@adobe.com.INVALID>.
I believe the warning was that the value of PURCHASED could change. The
Bindable subsystem does not know that the getter will always return the
same string literal. If other stuff could change, but didn't specify a
change event, I would hope the compiler would warn about that part of the
bindable expression.
IMO, one should never use plain [Bindable] with getters and setters. That
just wraps the getter/setter in another getter/setter with change event
detection. That adds up eventually both in code size and runtime.
Suddenly you are making two function calls instead of one to access the
underlying value.
You could use [Bindable("__NoChangeEvent__")] if you know a value doesn't
change but isn't a const. You probably don't want to add listeners for
when PURCHASED changes, just when the current location manager changes.
Of course, I could be wrong.
-Alex
On 6/19/17, 11:28 PM, "yishayw" <yi...@hotmail.com> wrote:
>It looks like changing the definitions of the interface and the class to
>
> [Bindable]function get PURCHASED():String;
>and
> [Bindable]public function get PURCHASED():String { return
>"PURCHASED"; }
>
>worked.
>
>So is it a bug that declaring the class and the interface as bindable was
>not enough?
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-How-Binding-works-tp57096p624
>85.html&data=02%7C01%7C%7Cdeee45fa75c74c1828da08d4b7a7f7f2%7Cfa7b1b5a7b344
>38794aed2c178decee1%7C0%7C0%7C636335379433525746&sdata=uK6hxHRAC%2BkVi8%2B
>igjlqgOKAypeFlS1EwLbZ6qNniDk%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.
RE: [FlexJS] How Binding works?
Posted by yishayw <yi...@hotmail.com>.
It looks like changing the definitions of the interface and the class to
[Bindable]function get PURCHASED():String;
and
[Bindable]public function get PURCHASED():String { return
"PURCHASED"; }
worked.
So is it a bug that declaring the class and the interface as bindable was
not enough?
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-Binding-works-tp57096p62485.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
RE: [FlexJS] How Binding works?
Posted by Yishay Weiss <yi...@hotmail.com>.
public function get PURCHASED():String { return "PURCHASED"; }
But the class has
[Bindable]public class DefaultStrings implements IUIStrings
From: Alex Harui<ma...@adobe.com.INVALID>
Sent: Tuesday, June 20, 2017 9:33 AM
To: dev@flex.apache.org<ma...@flex.apache.org>
Subject: Re: [FlexJS] How Binding works?
How is PURCHASED defined?
On 6/19/17, 11:10 PM, "yishayw" <yi...@hotmail.com> wrote:
>We have an mxml component where
>
> [Bindable]public var locStrings:IUIStrings =
>LocaleManager.localeStrings;
>...
> <js:beads>
> <js:ContainerDataBinding/>
> </js:beads>
>...
> <js:TextButton text="{locStrings.PURCHASED}"/>
>
>LocaleManager is declared thus:
>
> [Bindable]
> public class LocaleManager
>
>and it has:
> public static function get
>localeStrings():IUIStrings
>
>where IUIString is declared thus:
>
> [Bindable]public interface IUIStrings
>
>and its implementation is declares like this:
>
> [Bindable]public class DefaultStrings implements
>IUIStrings
>
>Can anyone explain why I'm seeing this?
>
> Data binding will not be able to detect assignments
>to 'PURCHASED'.
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-How-Binding-works-tp57096p624
>81.html&data=02%7C01%7C%7Cb672a18d7b984dac8a1008d4b7a56890%7Cfa7b1b5a7b344
>38794aed2c178decee1%7C0%7C0%7C636335368449199077&sdata=B9M048Wm1IsFYGOD%2F
>WAwrNhEmrJvAVEWXyPfP4MFuIQ%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How Binding works?
Posted by Alex Harui <ah...@adobe.com.INVALID>.
How is PURCHASED defined?
On 6/19/17, 11:10 PM, "yishayw" <yi...@hotmail.com> wrote:
>We have an mxml component where
>
> [Bindable]public var locStrings:IUIStrings =
>LocaleManager.localeStrings;
>...
> <js:beads>
> <js:ContainerDataBinding/>
> </js:beads>
>...
> <js:TextButton text="{locStrings.PURCHASED}"/>
>
>LocaleManager is declared thus:
>
> [Bindable]
> public class LocaleManager
>
>and it has:
> public static function get
>localeStrings():IUIStrings
>
>where IUIString is declared thus:
>
> [Bindable]public interface IUIStrings
>
>and its implementation is declares like this:
>
> [Bindable]public class DefaultStrings implements
>IUIStrings
>
>Can anyone explain why I'm seeing this?
>
> Data binding will not be able to detect assignments
>to 'PURCHASED'.
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-How-Binding-works-tp57096p624
>81.html&data=02%7C01%7C%7Cb672a18d7b984dac8a1008d4b7a56890%7Cfa7b1b5a7b344
>38794aed2c178decee1%7C0%7C0%7C636335368449199077&sdata=B9M048Wm1IsFYGOD%2F
>WAwrNhEmrJvAVEWXyPfP4MFuIQ%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.