Titanium JIRA Archive
Alloy (ALOY)

[ALOY-101] Allow Alloy.Models.MODEL_NAME notation

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2012-09-11T14:46:15.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime, XML
Labelsn/a
ReporterTony Lukasavage
AssigneeTony Lukasavage
Created2012-07-17T06:03:41.000+0000
Updated2014-01-28T23:18:01.000+0000

Description

Models, Collections, Components, and Widgets are currently accessible via the Alloy.get() methods. It would be nice to also have them available with the old Alloy.Models.MODEL_NAME format. To do so, the optimizer needs to be updated to convert those namespaces into the performance-friendly get() calls. Originally mentioned here: https://github.com/appcelerator/alloy/commit/8b0a21e448b0ec7c9f03dfa02eec0328e86d3a49#commitcomment-1589909

Comments

  1. Tony Lukasavage 2012-07-17

    This will likely be on hold for now given the reasons cited in the github issue: I think I might hold off on this one, mainly because it might be confusing to developers that the OO style is not valid at runtime. For example, this wouldn't generate correctly as it's a runtime constraint:
       var value = 'Models';
       var MODEL_NAME = Alloy[value].MODEL_NAME;
       
    It's perfectly valid JS, but our optimizer won't catch it and it will return undefined for MODEL_NAME. I think this needs to be a runtime assignment and I'm not sure offhand how to do that for a property without loading all the models, collections, components, and widgets at application load time. The function syntax seems to be the only way to defer the loading of these modules.

JSON Source