On May 18, 2014, at 5:20 PM, Michael DeMond <[email protected]> wrote:
>
> Total Node newb here. :) I just started a few weeks ago and have been
> learning it. I am curious if there is an equivalent to a window.onload event
> handler in NodeJS. Essentially, I am looking to execute a delegate when all
> of the code in my NodeJS application has loaded.
>
There is, as you may be aware, a difference between your code loading and your
code being ready. Since require() is synchronous, if you require() all your
modules at the outset your code has, speaking roughly, loaded. But is it ready?
Your modules may be doing asynchronous things during initialisation e.g,
connecting to a DB. Can you start accepting clients and processing requests
once your require()s are done? Depends on how you structure your code
(*mumble*promise*mumble*).
I hope I am not leading you down a side path,
--ravi
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/B98084A9-9FAD-4081-9E97-86AD0D957E8D%40g8o.net.
For more options, visit https://groups.google.com/d/optout.