title: RxJS + node.js HTTP server implementation?
body: <p>I 've been well with node.js until RxJS implementation.</p>
  
  <p>Here is my trial code studying-</p>
  
  <p><strong>Reactive-Extensions / rxjs-node
  <a href="https://github.com/Reactive-Extensions/rxjs-node" rel="noreferrer">https://github.com/Reactive-Extensions/rxjs-node</a></strong></p>
  
  <hr>
  
  <p>rx_http.js<br>
  (RxJS wrapper of the http lib of node.js)</p>
  
  <pre><code>var Rx = require("./rx.min");
  var http = require("http");
  for(var k in http)
  {
      exports[k] = http[k];
  }
  exports.createServer = function ()
  {
      var subject = new Rx.AsyncSubject();
      var observable = subject.asObservable();
      observable.server = http.createServer(function (request, response)
      {
         subject.onNext({ request:request, response:response });
         subject.onCompleted();
      });
      return observable;
  };
  </code></pre>
  
  <hr>
  
  <p>server.js </p>
  
  <pre><code>var http = require('./rx_http');
  
  // rxServer
  var serverObservable = http.createServer();
  var port = 3000;
  serverObservable.server.listen(port);
  console.log("Server listening on port: "+port);
  
  // HTTP request event loop function
  serverObservable.subscribe(function (data)
  {
      var req = data.request;
      console.log(req.headers);
  
      var res = data.response;
      res.writeHead(200, {'Content-Type':"text/html"});
      res.end("hello world");
  
      console.log("res content out");
  });
  
  // exceptiopn
  process.on('uncaughtException', function (err)
  {
      console.log(['Caught exception:', err.message].join(" "));
  });
  </code></pre>
  
  <hr>
  
  <p>The code ends up with one-time 'hello world' output to browser, and the RxServer stops reacting to another access (brwoser reload etc.).</p>
  
  <p>I'm on the way to learn RxJS thing, but few documentation found on the web.</p>
  
  <p>Tell me what's wrong with the code, and if you know better implementations, please share.
  Thank you.</p>