[TIMOB-10007] TiAPI: Be able to set a group of adhoc properties to any proxy at runtime - see description
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-08-15T20:57:19.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Sprint 2012-17 API, Release 3.0.0 |
Components | TiAPI |
Labels | core, look1 |
Reporter | Russell McMahon |
Assignee | Neeraj Gupta |
Created | 2012-07-17T13:02:44.000+0000 |
Updated | 2017-03-16T22:05:18.000+0000 |
Description
Like we do at create time where we can pass in an object representing properties, it would be helpful to have the same functionality available at runtime through an API like a applyProperties setter or getter or applyProperties({}) method. In Alloy we will dynamically set properties it would help performance if we could call a method to bulk set properties.
For example win1 = createWindow({
backgroundColor:'#336699',
borderWidth:8,
borderColor:'#999',
height:400,
width:300,
borderRadius:10,
opacity:0.92,})
currently is being done and the properties are being passed. A developer would like to have a way at runtime to change properties in a bulk for example win1.applyProperties({
backgroundColor:'#336699',
borderWidth:8,
borderColor:'#999',
height:400,
width:300,
borderRadius:10,
opacity:0.92,
});
Benefits - code speed, and reduced code size
Edit: In discussion, the word styles were dropped because 1) some properties are not logically part of a style and 2) we wanted to avoid confusion given how complex and interacting styles can be.
Note that this is different than applyLayout because this is to be done at the proxy level (IE, you can do this to sounds, to HTTPClient, etc) and does not delay or apply other logic like applyLayout does. Instead, foo.applyProperties({bar:5, baz:"bat"}) is identical to foo.bar=5; foo.baz="bat"; but is more compact and more importantly, reduces bridge traversal.
Note: this should be implemented in Ti.Proxy (Evented in Mobile Web's case).
The feature says this is for UI objects. In which case isn't this already supported by the updateLayout({}) call on ViewProxies?
Updating ticket to better represent the decisions made during architectural.
Closing ticket as fixed.