Answer the question
In order to leave comments, you need to log in
How to wait for all application components to be ready?
Greetings!
I'm new to the world of JS, and even more so to the world of server-side JS.
The problem is: There is a node.js/express server that uses modules to interact with mongo/mysql/redis/ and other services.
Is it possible (and how?) to make a handler for several events, which would be fired only after ALL of these events fire?
Those. start the server only when everyone is ready: both monga and radish and everything_that_has_event_ready?
Answer the question
In order to leave comments, you need to log in
The first option is a module that will be subscribed to all the necessary events and would store in itself which events have already worked and which have not. At the next event, check whether all events have already occurred. If yes - perform initialization.
The second option is to attach promises, remake events into promises, makePromise.all(promises).then(...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question