Skip to content

Instantly share code, notes, and snippets.

@xream
Last active November 3, 2016 16:03
Show Gist options
  • Save xream/b404395342dc41b62cfe0a3a2552c51d to your computer and use it in GitHub Desktop.
Save xream/b404395342dc41b62cfe0a3a2552c51d to your computer and use it in GitHub Desktop.
reactive programming with the Twitter streaming API
const conf = require('./conf').twit;
const Twit = require('twit')
const Rx = require('rxjs/Rx')
const subject = new Rx.Subject()
.map(({
text,
user: {
screen_name
}
}) => `@${screen_name}: ${text}`)
subject.subscribe({
next: v => console.log('next: ' + v),
error: v => console.log('error: ' + v),
complete: () => console.log('complete'),
})
new Twit(conf)
.stream('user')
.on('tweet', e => subject.next(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment