title: nodejs using callback and event
body: <p>I am new to nodejs programming. so be patient with me.</p>
  
  <p>I have two nodejs modules. One passes passes a message to another nodejs module. the second processes it and pass result back
  to the first module.</p>
  
  <p><strong>method 1</strong></p>
  
  <p>first module</p>
  
  <pre><code>:
  secondModule.callFunction(message, function(data){
      //deal with the return message from the second module
  
  })
  :
  </code></pre>
  
  <p>second module</p>
  
  <pre><code>:
  function callfunction(message, callback){
  
     //asynchornous functions for processing
     callback(data);
  } 
  :
  </code></pre>
  
  <p><strong>method 2</strong></p>
  
  <p>same thing but done using event emitters in the second module</p>
  
  <p>first module</p>
  
  <pre><code>:
  secondModule.callFunction(message){
  
  })
  secondModule.on('done_event', function(data){
      //deal with the reply
  });
  :
  </code></pre>
  
  <p>second module (uses event emitter)</p>
  
  <pre><code> :
  
   function callFunction(message){
  
  //asynchornous functions for processing
  self.emit('done_event', data);
   } 
   :
  </code></pre>
  
  <p>Are they both correct. what is the difference in these things (both are asynchornous)
  or have i done something stupid.</p>
  
  <p>Thanks in advance</p>