I'm trying to get some confidence with RXJS and FRP. This code handles file sharing via socket.io. I need some advice about general RXJS style and reactive programming.

io.sockets.on('connection', function (socket) {
  var msgStream = Rx.Observable.fromEvent(socket, 'message');
  msgStream.filter(function(x) {
    return x.type === 'get';
  }).do(function() {
    socket.send({type: 'start'});
  }).do(function() {
    msgStream.filter(function (x) { return x.type === 'next'; })
        function(a, b) {·
          return [a, b];
      .do(function(data) {
        socket.send({type: 'chunk', data: data});
      }).subscribe(undefined, undefined, function() {
        socket.send({type: 'end'});
  • \$\begingroup\$ What happens for larger files? \$\endgroup\$ Jul 30, 2015 at 16:14
  • \$\begingroup\$ It takes something like 10 minutes to send file 400Mb weight \$\endgroup\$ Jul 30, 2015 at 16:16
  • \$\begingroup\$ And how fast is your internet? And how fast is the internet of the receiving end? How long does it take to send a 40 MB file? \$\endgroup\$ Jul 30, 2015 at 16:18
  • \$\begingroup\$ I'm running the application locally. Actually, the question isn't about performance. I added some explanation \$\endgroup\$ Jul 30, 2015 at 16:23


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.