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&amp;data=02%7C01%7Caharui%40adobe.com%7C68f075afc18547f7037c08d6fafa6fd0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636972350882055963&amp;sdata=q6PWd4TcVwmnVlw2djwDKSvteiVT8dzrW104mzuV%2FUw%3D&amp;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&amp;data=02%7C01%7Caharui%40adobe.com%7C68f075afc18547f7037c08d6fafa6fd0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636972350882065960&amp;sdata=LdKimckgxxIWf5VObhdXV9%2BgEzAH403uv%2F1Okz7SfP0%3D&amp;reserved=0
    > >>
    > >>
    > >
    > >    --
    > >    Carlos Rovira
    > >
    > 
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7C68f075afc18547f7037c08d6fafa6fd0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636972350882065960&amp;sdata=LdKimckgxxIWf5VObhdXV9%2BgEzAH403uv%2F1Okz7SfP0%3D&amp;reserved=0
    > >
    > >
    >
    >
    
    -- 
    Carlos Rovira
    
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7C68f075afc18547f7037c08d6fafa6fd0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636972350882065960&amp;sdata=LdKimckgxxIWf5VObhdXV9%2BgEzAH403uv%2F1Okz7SfP0%3D&amp;reserved=0
    

Reply via email to