royale-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] aharui commented on issue #343: Question : IS there a way to embed third party components within a Royale app
Date Sun, 11 Nov 2018 01:57:34 GMT
aharui commented on issue #343: Question : IS there a way to embed third party components within
a Royale app
URL: https://github.com/apache/royale-asjs/issues/343#issuecomment-437636992
 
 
   Based on your description above, it should be possible.  I want to point out that having
any "multi-type" APIs is not recommended when using strongly-typed languages, so having a
property that takes either a String or a Function is not a best practice.
   
   Also, for folks coming from the Flex world, having an attribute named "itemClick" that
isn't an event handler will also be unexpected and cause confusion.
   
   So, you have some choices:
   1) to exactly reproduce your multi-type API, you would define:
      public var itemClick:Object;
   
   The problem with doing this is that:
   A) folks could pass a Number and the compiler will not care
   B) If folks pass a method, the compiler will not know to convert it to a closure (bind
'this')
   
   2) You could define 2 properties:
     public var itemClick:Function;
     public var itemClickFunctionName:String;
   
   Users would assign one or the other.  The compiler will generate closures for methods assigned
to itemClick because it is now of type Function.
   
   3) Wrap the grid and have it dispatch an Event.
   
   This will make it work just like Flex.  The Grid won't have to callback anything per-se.
 The wrapping code would always assign itemClick to some function that dispatches an Event.
 I would recommend this pattern.
   
   I'm not sure I understand your second question.  If you are asking how to make your JS
component available in MXML, the answer is that MXML is oriented towards getter/setters (which
map to Object.defineProperties() in JS). So the dataProvider setter would call your setDataProvider
method. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Mime
View raw message