flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: SimpleBinding changes make createjs sample stop working
Date Thu, 02 May 2013 21:54:55 GMT
Hi Carlos,

I saw the changes.

I think it is a good fix, but you might want to add a comment that the
non-getter approach is likely to fail for non-public variables when
minified.

Right now, binding in FlexJS only works for public properties and your fix
makes it work for public variables.  Note that in some cases, the backing
variable for a public get/set is the same name because in JS the pattern
looks like:

    /** @private */
    var foo;

    /** @expose */
    function get_foo()
    {   
        return this.foo;
    }

The question is, what did the AS look like?  If it looked like

    private var _foo;
    public function get foo()
    {
        return this._foo;
    }

Then the JS code for your failure case should be changed to look like the
recommended pattern and then you don't need the [this.sourceID] code path as
there will be a get_ function.

If the AS looked like:

    public var foo;

Then the JS should be

/** @expose */
Someclass.prototype.foo;

If they forget to use @expose then it will likely fail when minified.

One more minor thing:  Do you happen to know if try/catch is more efficient
than doing a property lookup to see if it is undefined before making a call?

Anyway, thanks for contributing.  We can use all the help we can get.


On 5/2/13 2:35 PM, "Carlos Rovira" <carlos.rovira@codeoscopic.com> wrote:

> Hi Alex,
> 
> I commit a solution that fixes the problem, but I don't know if is
> compliant with the motivation you make this change (minified version).
> 
> I think binding should work even if we don't have a getter/setter setup,
> but I'm to new to this new framework that maybe this is not what you have
> in mind.
> 
> So it's up to you to change if you see some problem with this fix.
> 
> 
> 2013/5/2 Alex Harui <aharui@adobe.com>
> 
>> 
>> 
>> 
>> On 5/1/13 3:40 PM, "Carlos Rovira" <carlos.rovira@codeoscopic.com> wrote:
>> 
>>> Hi Alex
>>> 
>>> this latest change in SimpleBinding:
>>> 
>>> -    this.source = this.document[this.sourceID];
>>> +    this.source = this.document['get_' + this.sourceID]();
>>> 
>>> 
>>> Makes the createjs sample to not generate controls far beyond a
>>> SimpleBinding.
>>> 
>>> I need to change the sample code or it's a bug?
>> Well, using getters is correct.  Are you binding to something that isn't a
>> getter in AS?  Maybe the JS version of that property should have been a
>> get/set pair.
>> 
>> But if you want, you can also try to make SimpleBinding tolerant and find
>> things that aren't getters.
>>> 
>>> Thanks
>> 
>> --
>> Alex Harui
>> Flex SDK Team
>> Adobe Systems, Inc.
>> http://blogs.adobe.com/aharui
>> 
>> 
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Mime
View raw message