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 2019/06/22 02:26:55 UTC

[GitHub] [royale-compiler] aharui commented on issue #88: RemoteObject and Listeners on Opretion level - workaround

aharui commented on issue #88: RemoteObject and Listeners on Opretion level - workaround
URL: https://github.com/apache/royale-compiler/issues/88#issuecomment-504619283
 
 
   This is (currently) a "fact-of-life" for Royale.  RemoteObject is a Proxy so that it can have properties that are the names of the operations (like 'getText').  The compiler cannot know what the type of a Proxy property is for JS output, so it assumes the type of the property is also a Proxy (in order to handle nested ObjectProxy trees).
   
   I suppose the compiler could output lots of code or call a function that tests the value returned and then knows how to properly access the results, but that could be heavy and slow.
   
   In Flash/AIR the runtime knows the type and determines how to access the property.
   
   So at least for now, Royale code may occasionally need more explicit type-casting, mainly when handling XML and Proxy, but also other dynamic objects including dynamic access `obj[propName]`.
   
   So your code will need to explicitly type the Operation so instead of just:
   
   `remoteObject.getText.addEventListener(ResultEvent.RESULT, 
   getdataResultHandler);`
   
   which works just fine in SWF, your code will need to be:
   
   `(remoteObject.getText as Operation).addEventListener(ResultEvent.RESULT, 
   getdataResultHandler);`
   
   You can use ASDoc comment directives for the method
   
   ```
   /**
    * @royaleignorecoercion mx.rpc.remoting.Operation
    */
   ```
   
   to suppress the call to `Language.as()`
    

----------------------------------------------------------------
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


With regards,
Apache Git Services