title: How to properly turn WS Server to RXJS Api without Subjects in NodeJs
body: <p>What's the proper way to turn the famous ws module into a reactive api in Node.js?
  I understand that subjects can help with bridging non-reactive to reactive events, but their the problem is that they have a much harder time disposing their dependent objects.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var WebSocketServer = require('ws').Server;
  var wss = new WebSocketServer({ port: 8080 });
  var Rx = require('rx');  
  
  
  var connectionMessageSubject = new Rx.Subject();
  
  wss.on('connection', function connection(client) {
    ws.on('message', function incoming(message) {
      connectionMessageSubject.onNext({
        client: client,
        message: message
      });
    });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>I can't use their built in fromEvent method because, it registers so many different events that NodeJS throws a warning when 30 or more clients connect. </p>
  
  <p>For example...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var WebSocketServer = require('ws').Server;
  var wss = new WebSocketServer({port:8080});
  
  var connectionMessageObservable;
  
  //this uses a tremendous amount of memory and throws warnings that the event emitter has a maximum of 30 listeners 
  wss.on('connection', function connection(client){
    connnectionMessageObservable = Rx.Observable.fromEvent(client, 'message');
  });</code></pre>
  </div>
  </div>
  </p>