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
ES6 one liner that i use, using ES7 bind syntax:
(read $
as stream
)
import { Observable } from 'rxjs'
// create socket
const message$ = Observable.create($ => socket.on('message', ::$.next))
// translates to: Observable.create($ => socket.on('message', $.next.bind(this)))
// filter example
const subscription = message$
.filter(message => message.text !== 'spam')
//or .filter(({ text }) => text !== 'spam')
.subscribe(::console.log)