| Page 1 of 1 | [ 4 posts ] |
|
hi,
one of the possible use case is to make wrapper YUI3 object that extends base or widget to wrap YUI2 object. Instead of directly use YUI2 class, I create a wrapper and store the YUI2 object as a private property. say, yui3datatable._delegate = new YAHOO.widget.DataTable(...) Ideally, Y.mix could be used to copy all properties from the delegate to the outer class, while each function is binded like Y.bind( yui2database_function, yui3datatable ) . For sure this require Y.mix to have extra argument to for binding, or expose a function for us to "transform" each property when it is being mixed. if the Y.mix could be done to implement delegate, then the other tasks are:
then a pseudo YUI3-to-YUI2-delegate-wrapper is more or less done. does it make sense? |
|
forgotten to mention, the render() will be handled separately. the render code will be splitted to renderUI, bindUI, and syncUI in case by case basis. some transformation will be done, e.g. an id with # will be converted back to the YUI2 style.
the whole objective is to YUI2 features with YUI3 in a more YUI3-ish style. |
|
Seems like it could lead to complicated debugging. It would be interesting though to see this approach on a yui2 widget that's moderate in [API] size, say the TabView widget.
Eric Ferraiuolo
What types of benefits would you be looking for that make doing the wrapping worth it? |
|
it's just an experimental idea and i dare not to say it is good. There are two issues:
1. Y.mix to support binding 2. should we/how do we wrap YUI2 with YUI3 re. 1, i just got a new usage that is to do some kind of pseudo AOP to do sth before and after any function. e.g. say the Y.mix is enhanced with an additional argument that take a function to process the function before it is assigned to the receiver, e.g. function(prop, r, s){ if (Y.Lang.isFunction(prop) ){ return Y.bind( prop, r._delegate) } return prop; } one usage is to add logging before the fn is called, e.g. function(prop, r, s){ if (Y.Lang.isFunction(prop) ){ return function() { Y.log( "target: " + r._delegate + ", function: " + prop + ", arguments: " + arguments, "debug", "Y.mix injected logger") Y.bind( prop, r._delegate) } } return prop; } re. 2, the reasons/benefits to do in this way:
i dare not to say its a good approach. just to evolve an idea. |
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group