Take a look at UIModuleLoader and UIModuleUtils. Already it creates several HTML script and link tags to load a js-debug module. The patterns are already there to use as a template to load another script tag that will add other script tags to the DOM or do just about anything you want. You can manually code that additional JS file or have the compiler autogenerate it from addtionalHTML. I don't think you want to generate HTML and write it to innerHTML, but I could be wrong about that.
In the compiler, the MXMLRoyalePublisher is where the inject_html data is represented as additionalHTML and can be modified to be working JS. HTH, -Alex On 6/28/19, 3:10 PM, "Carlos Rovira" <[email protected]> wrote: For watt you say, I'm more with the second part of your response where we can alter the compiler to modify the additionalHTML, but I think that should be based on inject_html like we do in Application. I remember that this problem is less related to a loading of resources problem, that we need to wait until the bytes was completely downloaded and we signaled that event. This is more an Annotation-metadata problem where we want that if the user *use* a class we want the html gets decorated with a line of code, and that should happen only once as currently happens when we use the same class in the Application. but If I try. to imagine how to do that, I don't get any idea, since that can be done like we do with main application. In this case, we only can add to the HTML once the user loads the module and that means can't be a preprocess in the compiler like is actually in application El sáb., 29 jun. 2019 a las 0:01, Alex Harui (<[email protected]>) escribió: > In a quick peek at the code, the ModuleLoader already loads more than one > file. It should be relatively simple to have a subclass or alternate > ModuleLoaderWithPreloader that loads an additional file that loads the > third-party JS. > > Also, it appears that it should be relatively simple to alter the compiler > to take the additionalHTML and output it to be that additional file. > > -Alex > > On 6/27/19, 5:24 AM, "Carlos Rovira" <[email protected]> wrote: > > I'm with you that we can make the compiler optimize the class and just > add > the constants used, but I think that's is just an optimization issue. A > user will want to use constants this way. They even could create a > reduced > class with just the constants he needs. > > About preloader, I'm interested in see how to do it. Maybe some example > from you and Yshay could be great to add to blog examples, I can help > with > that If you want, if you provide an email with the code, or prepare a > project, I can do the rest. It would be good to all of us, so we can > learn > how to do it. > > But as I stated before in my response to Alex, I don't think the > preloader > is the real problem in this case. Although we use a preloader, I think > we > still need to solve the inject_html issue in modules don't you think? > > > > El jue., 27 jun. 2019 a las 10:05, Harbs (<[email protected]>) > escribió: > > > I also don’t know that abstracting this too much is a good thing. > It’s a > > fair trade-off to require declaring external dependencies. It also > allows > > for controlling where the dependencies are coming from, versioning, > etc. > > > > To me the pattern should be something like this: > > > > 1. Add a preloader bead to the app. > > 2. Declare a list of dependencies for the preloader (which can > control > > where these dependencies are loaded from). > > > > In the case of something like MaterialIconType.SEARCH, I don’t think > the > > MaterialIconType class should be included in the final app at all if > all > > that’s used is some constants. I hope we eventually optimize away all > > constants in the compiler. > > > > Harbs > > > > > On Jun 27, 2019, at 10:29 AM, Alex Harui <[email protected] > > > > wrote: > > > > > > I'm pretty sure in related threads I mentioned that a preloader is > > needed. > > > > > > -Alex > > > > > > On 6/26/19, 8:16 AM, "Carlos Rovira" <[email protected]> > wrote: > > > > > > Thanks Spiros, > > > > > > My real problem is the following. I'm trying to improve > Modules. I > > found > > > that inject_html don't work with modules, Inject_html is > processed by > > > compiler. To solve in an easy way I'm trying to load CSS and JS > with > > > javascript appending to head. > > > > > > When I load the module and I use a class that needs to attach > some > > JS, I > > > want to run a function like "loadJavascript" > > > > > > I created as well "loadCSS" (still not commited). > > > > > > The real use case I'm trying is to use MaterialIconType, that > was > > using > > > inject_html. I removed the inject_html directive, > > > then added > > > > > > loadCSS(' > > > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Ffonts.googleapis.com%2Ficon%3Ffamily%3DMaterial%2BIcons&data=02%7C01%7Caharui%40adobe.com%7C0fba1437b370405d8d0208d6fc1576b0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636973566476749021&sdata=13kFGAeYPKv3uETc3J%2F8zzV0M%2F3jdWM5TdvtDneVu7w%3D&reserved=0 > ' > > ); > > > > > > in the constructor > > > > > > then in my real module I want just to use as always > > > > > > <js:FontIcon text="{MaterialIconType.SEARCH}" material="true"/> > > > > > > accesing this way does not run the constructor, so the loadCSS > code > > does > > > not run :( > > > > > > > > > We have hundreds of public static vars like > > > > > > public static const SEARCH:String = 'search'; > > > > > > So I think the current way you propose, although valid, will > not be > > the > > > best here, since will means lots of lines of code. > > > > > > But thanks for your suggestion > > > > > > Hope others could give as well some ideas on how to solve this > > > > > > thanks > > > > > > > > > > > > El mié., 26 jun. 2019 a las 17:05, spiros (<[email protected] > >) > > escribió: > > > > > >> It is possible with static getter and seter. > > >> > > >> Maybe will help you the code below > > >> > > >> Spiros. > > >> > > >> public class Variable > > >> { > > >> > > >> private static var _textData:String; > > >> > > >> public static function get textData():String > > >> { > > >> if( _textData ==null) > > >> { > > >> initailizeVariable(); > > >> } > > >> return _textData; > > >> } > > >> > > >> public static function set > textData(value:String):void > > >> { > > >> _textData = value; > > >> } > > >> > > >> public static function initailizeVariable():void > > >> { > > >> _textData = "The quick brown fox jump over > the > > >> lazy dog."; > > >> } > > >> > > >> > > >> public function Variable() > > >> { > > >> } > > >> } > > >> > > >> > > >> > > >> > > >> > > >> -----Original Message----- > > >> From: Carlos Rovira [mailto:[email protected]] > > >> Sent: Wednesday, June 26, 2019 5:49 PM > > >> To: [email protected] > > >> Subject: Trying to run a function on a class that is not > instantiated > > >> > > >> Hi, > > >> > > >> I need to run a function when I access a public static var in a > class. > > >> Trying to run the function in the constructor seems not to work > since > > >> there's no instance of that class. Do we have some way to do this? > > >> > > >> -- > > >> Carlos Rovira > > >> > > > https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0fba1437b370405d8d0208d6fc1576b0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636973566476749021&sdata=vgPgFnpmCTXvuRubkZu9ypRKe7SukeRF2ean2ytFKfQ%3D&reserved=0 > > >> > > >> > > > > > > -- > > > Carlos Rovira > > > > > > https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0fba1437b370405d8d0208d6fc1576b0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636973566476749021&sdata=vgPgFnpmCTXvuRubkZu9ypRKe7SukeRF2ean2ytFKfQ%3D&reserved=0 > > > > > > > > > > > > -- > Carlos Rovira > > https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0fba1437b370405d8d0208d6fc1576b0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636973566476749021&sdata=vgPgFnpmCTXvuRubkZu9ypRKe7SukeRF2ean2ytFKfQ%3D&reserved=0 > > > -- Carlos Rovira https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0fba1437b370405d8d0208d6fc1576b0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636973566476749021&sdata=vgPgFnpmCTXvuRubkZu9ypRKe7SukeRF2ean2ytFKfQ%3D&reserved=0
