javascript - How to use RxJs with Socket.IO on event -


i want use rxjs inside of socket.on('sense',function(data){});. stuck , confused few documentation available , lack of understanding rxjs. here problem.

i have distsensor.js has function pingend()

function pingend(x){ socket.emit("sense", dist); //pingend fired when interrupt generated. } 

inside app.js have

io.on('connection', function (socket) {     socket.on('sense', function (data) {         //console.log('sense app4 called ' + data);     }); }); 

the sense function gets lots of sensor data want filter using rxjs , don't know should next use rxjs here. pointers right docs or sample help.

i think can use rx.observable.fromevent (https://github.com/reactive-extensions/rxjs/blob/master/doc/api/core/operators/fromevent.md).

here's how did similar thing using bacon.js, has similar api: https://github.com/raimohanska/bacon-minsk-2015/blob/gh-pages/server.js#l13

so in bacon.js go like

io.on('connection', function(socket){   bacon.fromevent(socket, "sense")     .filter(function(data) { return true })     .foreach(function(data) { dealwith(data) }) }) 

and in rxjs you'd replace bacon.fromevent rx.observable.fromevent.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -