Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Last active November 22, 2016 01:05
Show Gist options
  • Save TyrfingMjolnir/62949a8b3d2ca002a779fd0bbe896b7b to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/62949a8b3d2ca002a779fd0bbe896b7b to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const Rx = require( 'rxjs' ),
s$ = Rx.Observable
.interval( 100 )
.take( 10 )
.filter( function( v ) {
if( v % 2 == 0 ) {
return v;
}
})
.map( v =>
'' + v + ' ' + Date.now()
)
/*
Alternatively you can replace the line below the comment if you'd like to separate the init and the execute of your observable with the following one:
; s$.subscribe(
*/
.subscribe( v => {
console.log( v );
}, err => {
console.log( err );
}, completed => {
console.log( 'Ding! Ding! Ding!' );
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment