Something like

__ATMAIN__.push(function() {
  doSomething();
});

should work.

Another option is to just define a main() function, as that is called right
after the ATMAINs, after all preloading is done. (Or if you have a main, to
add your code at its beginning.)

- Alon




On Tue, Apr 29, 2014 at 2:19 PM, <[email protected]> wrote:

> Thanks for your quick reply!  I don't quite understand what you mean by
> push a function to __ATMAIN__.  Is there a code sample in the docs?
>
>
> On Tuesday, April 29, 2014 4:09:38 PM UTC-5, Alon Zakai wrote:
>
>> Yes, you can push a function to __ATMAIN__, those are called when it is
>> safe to run main(), which means all preloads and other async stuff has
>> arrived.
>>
>>
>> On Tue, Apr 29, 2014 at 2:04 PM, <[email protected]> wrote:
>>
>>> Is there a way to get notified when preloads are finished?
>>>
>>>
>>> On Friday, April 25, 2014 5:28:20 PM UTC-5, Alon Zakai wrote:
>>>
>>>> Preloads etc. work relative to your current directory, as it will show
>>>> up in the JS file system relative to there. So ../ paths don't make sense
>>>> for that. You can use the @ syntax (see "@ mapping" in
>>>> https://github.com/kripken/emscripten/wiki/Filesystem-Guide ).
>>>>
>>>> - Alon
>>>>
>>>>
>>>>
>>>> On Thu, Apr 24, 2014 at 10:26 PM, <[email protected]> wrote:
>>>>
>>>>> Thank you for the quick fix!
>>>>>
>>>>> I still can't get relative or absolute paths to work like --preload-file
>>>>> ../Folder/File.txt.  It only works if I copy the file to my
>>>>> working directory and do --preload-file File.txt.
>>>>>
>>>>>
>>>>> On Thursday, April 24, 2014 8:41:08 PM UTC-5, Alon Zakai wrote:
>>>>>
>>>>>> I pushed a commit to incoming that should fix this, please check.
>>>>>>
>>>>>> - Alon
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 24, 2014 at 3:06 PM, <[email protected]> wrote:
>>>>>>
>>>>>>> I think I understand the issue.  I'm outputting to JS not HTML so no
>>>>>>> canvas is defined so this must be a bug when using --preload-file and
>>>>>>> outputting only to JS.  If I omit --preload-file then the code for 
>>>>>>> canvas
>>>>>>> is omitted.
>>>>>>>
>>>>>>>
>>>>>>> On Thursday, April 24, 2014 3:41:13 PM UTC-5, Alon Zakai wrote:
>>>>>>>
>>>>>>>> Which browser is this on? (Older ones might not have
>>>>>>>> requestPointerLock I suppose?)
>>>>>>>>
>>>>>>>> - Alon
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Apr 23, 2014 at 9:58 PM, <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> Thanks for your response!  This is really an amazing project.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I tried --preload-file but it's not working for me.  It creates
>>>>>>>>> the .data file but it's not being loaded.  I get this error in the 
>>>>>>>>> console.
>>>>>>>>>
>>>>>>>>> TypeError: 'undefined' is not an object (evaluating
>>>>>>>>> 'canvas['requestPointerLock']')
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I also cannot get relative paths to work with --embed-file or
>>>>>>>>> --preload-file.  If I do something like --preload-file
>>>>>>>>> ../Folder/File.txt it doesn't create a .data file.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> It would be great to have an option to embed as a string.  The
>>>>>>>>> only escaped character in my text file is the newline character.
>>>>>>>>>
>>>>>>>>> On Wednesday, April 23, 2014 9:57:11 PM UTC-5, Alon Zakai wrote:
>>>>>>>>>
>>>>>>>>>> --preload-file will save it as a binary file on the side, which
>>>>>>>>>> is more optimal.
>>>>>>>>>>
>>>>>>>>>> We can't use a string in embed-file because not all characters
>>>>>>>>>> can be represented that way without escaping, which i'm not sure how 
>>>>>>>>>> hard
>>>>>>>>>> would be to implement. In any case, --preload-file is the recommended
>>>>>>>>>> approach.
>>>>>>>>>>
>>>>>>>>>> - Alon
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 23, 2014 at 5:21 PM, <[email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> I'm using the --embed-file option to embed a 300KB text file
>>>>>>>>>>> but it's adding an additional 1.4MB to my Javascript file.  Is
>>>>>>>>>>> it possible to have it embedded as a string?  After looking at
>>>>>>>>>>> the code produced it's storing the text file as an array of numbers 
>>>>>>>>>>> which
>>>>>>>>>>> also significantly increases build time if I use the --closure 
>>>>>>>>>>> option
>>>>>>>>>>> too.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>> Google Groups "emscripten-discuss" group.
>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from
>>>>>>>>>>> it, send an email to emscripten-discuss+unsubscribe
>>>>>>>>>>> @googlegroups.com.
>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "emscripten-discuss" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to [email protected].
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "emscripten-discuss" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "emscripten-discuss" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to