title: JavaScript - How to create custom API listener for Socket.io events?
body: <p>i'm trying to create custom <strong>API listener</strong> for 3-rd developers on my site. It should look like this:</p>
  
  <pre><code>// Function will be fired when any user joins to room
  API.on('user-join', function(data){
    console.log(data); // Data is object with user id and name
  });
  </code></pre>
  
  <p>I have <strong>Socket.io listener</strong> too:</p>
  
  <pre><code>// This handler is fired every time when anyone joins
  socket.on('user-join', function(data){
    // Probably here i should call a callback to API.on('user-join') with that data object
  });
  </code></pre>
  
  <p>How can i send callback in Socket.io handler to my custom created API? Please let me know how to do this. Thanks.</p>