You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2021/01/10 13:39:38 UTC

[GitHub] [royale-compiler] SemiConscious opened a new issue #174: Bindable static vars never dispatch events

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:
users@infra.apache.org



[GitHub] [royale-compiler] SemiConscious commented on issue #174: Bindable static vars never dispatch events

Posted by GitBox <gi...@apache.org>.
SemiConscious commented on issue #174:
URL: https://github.com/apache/royale-compiler/issues/174#issuecomment-757487946


   Ok it turns out the changes did work, but chrome was caching the .js files. I have created a pull request https://github.com/apache/royale-compiler/pull/175. 
   
   The next issue is to figure out why when the event is called there are never any listeners :(


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [royale-compiler] joshtynjala commented on issue #174: Bindable static vars never dispatch events

Posted by GitBox <gi...@apache.org>.
joshtynjala commented on issue #174:
URL: https://github.com/apache/royale-compiler/issues/174#issuecomment-759781069


   Solution looks good to me. I merged #175.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [royale-compiler] joshtynjala closed issue #174: Bindable static vars never dispatch events

Posted by GitBox <gi...@apache.org>.
joshtynjala closed issue #174:
URL: https://github.com/apache/royale-compiler/issues/174


   


----------------------------------------------------------------
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:
users@infra.apache.org