I call a function that stacks two async calls and calls a callback when they have both completed.
I am using a really simple method to keep track of the calls that have not completed
lock++
lock–
The problem is that the program exits before the operation of the two functions is complete. I noticed this was the problem when I was debugging and gave the process time to complete before it exits.
How can I fix this? (At the moment I am at a bit of a loss on how to exactly explain my problem please ask me anything you need to so I can clarify the question)
—–EDIT
With the script below why when I run it does it just exit? I thought that by calling on I was registering to the event que and the script should continue to run?
var events = require('events');
var eventEmitter = new events.EventEmitter();
eventEmitter.on('spo',function(){
console.log('spo');
});
COMING From a Git Hub thread.
I think that what they are saying is that it is the handle outside of Node into C land that holds the script open.