The issue should be clear.

If MySuperClass.js has not yet been loaded when MySubClass.js is loaded, 
goog.inherits(MySubClass, MySuperClass); which is in MySubClass.js will cause 
an error.

This code is being added to the JS file right after the constructor is being 
defined, but it’s not wrapped in an initializer function so it’s evaluated as 
soon as the JS file is loaded.

If it would be wrapped in an init function, it could be evaluated only after 
all files are loaded, so all classes would be defined.

We’ve been spending the better part of the last day trying to distill this down 
to a test case which causes the compiler to load the classes in the wrong 
order. We’re getting closer, but we’re not there yet. Even if we find the 
specific root cause in my case for the files to be loaded in the wrong order, I 
still think it’s a design flaw which should be fixed. The order of loading 
files should not matter.

On Jul 18, 2016, at 9:38 AM, Alex Harui <aha...@adobe.com> wrote:

> A simple test case might help us understand the issue better.
> 
> -Alex
> 
> On 7/17/16, 11:35 PM, "Harbs" <harbs.li...@gmail.com> wrote:
> 
>> To be clear:
>> 
>> I’m currently struggling with goog.inherits(MySubClass, MySuperClass);
>> For some reason (which I’m not totally clear on) MySubClass is being
>> loaded first, and MySuperClass is not yet defined when this code is
>> called.
>> 
>> If goog.inherits was mored to an initializer which is lazy-evaluated, I
>> believe this error would go away.
>> 
>> On Jul 18, 2016, at 9:25 AM, Harbs <harbs.li...@gmail.com> wrote:
>> 
>>> I’m also not sure how the prototype is being setup.
>>> 
>>> It could be you’ve already solved my concerns there, but it looks like
>>> a lot of the prototype is being setup outside the constructor.
>>> 
>>> On Jul 18, 2016, at 9:10 AM, Alex Harui <aha...@adobe.com> wrote:
>>> 
>>>> 
>>>> 
>>>> On 7/17/16, 11:02 PM, "Harbs" <harbs.li...@gmail.com> wrote:
>>>> 
>>>>> Well, I guess the question is where the init functions would be
>>>>> called.
>>>>> 
>>>>> My idea was that the “instance init function call would be added to
>>>>> the
>>>>> constructor as the first thing that happens (with the exception of
>>>>> calling init on the super-class first).
>>>> 
>>>> Right now, instance initialization happens in the constructor.  I can't
>>>> immediately think of a a scenario where that isn't sufficient.
>>>> 
>>>>> 
>>>>> The class initializers is more of a question. I figured that might
>>>>> need
>>>>> to be added into whatever code loads the js files.
>>>> 
>>>> I think I would end each .js file with:
>>>> 
>>>> SomeClass.cinit = function()
>>>> {
>>>> // all class initializer code
>>>> }
>>>> SomeClass.cinit();
>>>> 
>>>> 
>>>> Maybe I'm not thinking of some scenario where more is needed.
>>>> 
>>>> -Alex
>>>> 
>>> 
>> 
> 

Reply via email to