How to use RxJs with Socket.IO on event

后端 未结 6 900
温柔的废话
温柔的废话 2021-02-02 12:56

I want to use RxJS inside of my socket.on(\'sense\',function(data){});. I am stuck and confused with very few documentation available and my lack of understanding R

6条回答
  •  余生分开走
    2021-02-02 13:35

    You can create an Observable like so:

    var senses = Rx.Observable.fromEventPattern(
        function add (h) {
          socket.on('sense',h);
        }
      );
    

    Then use senses like any other Observable.

提交回复
热议问题