SemiConscious opened a new issue #174:
URL: https://github.com/apache/royale-compiler/issues/174


   In my case, anyway. I am porting a large flex application which has a 
`[Bindable]` globals class consisting of static variables. In the compiled js 
for the globals class, I get:
   
   ```
   /**
    * Compiler generated
    * Static Binding support
    * @private
    * @type {org.apache.royale.events.EventDispatcher}
   */
   globals._bindingEventDispatcher;
   
   Object.defineProperties(globals, /** @lends {globals} */ {
   /**
    * @export
    * @type {org.apache.royale.events.EventDispatcher}
    */
   staticEventDispatcher: {
     get: function() {
                return globals._bindingEventDispatcher
        || (globals._bindingEventDispatcher = new 
org.apache.royale.events.EventDispatcher());
       }
     },
   /**
    * @type {XML}
    */
   Policies: {
     get: function() {
       return globals.Policies_;
     },
     
     set: function(value) {
        var oldValue = globals.Policies_;
        if (value != oldValue) {
                        globals.Policies_ = value;
                        var dispatcher = globals._bindingEventDispatcher;
                        if (dispatcher) 
dispatcher.dispatchEvent(org.apache.royale.events.ValueChangeEvent.createUpdateEvent(
                                globals, "Policies", oldValue, value));
         }
       }
     },
   
   ...
   ```
   
   In my case: `globals._bindingEventDispatcher` is never initialized, so the 
`ValueChangeEvent` is never dispatched. So my question is: should 
`_bindingEventDispatcher` be replaced by `staticEventDispatcher` in the setter 
function, or does something need fixing so that `_bindingEventDispatcher is 
initialized in the class constructor? 
   
   In an effort to contribute: there are two instances where it seems like this 
code could be generated: `BindableHelper::generateBindableSetter` and 
`BindableEmitter::emitBindableStaticVarDefineProperty`, but I have tried 
modifying both of these to see what would happen, and neither seems to make the 
change I am expecting despite doing a compiler rebuild from clean, so I am 
obviously missing something obvious.
   
   I could work around this I suspect by making the variables non-static, but 
if it's simple matter to fix I'd rather fix it. I am going to try and find 
where this code is generated and try a fix and will post a pull request for 
your examination if I create something that looks correct.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to