Last active
November 22, 2016 01:05
-
-
Save TyrfingMjolnir/62949a8b3d2ca002a779fd0bbe896b7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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