Created
February 22, 2016 23:14
-
-
Save anonymous/b83154fe514cb30df701 to your computer and use it in GitHub Desktop.
JS Bin RxJS Hot Observable // source https://jsbin.com/qazuse
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="RxJS Hot Observable"> | |
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
See the console. | |
<script id="jsbin-javascript"> | |
console.clear() | |
var data = [1,2,3,4,5,6,7,8,9]; | |
var stream = Rx.Observable.interval(1000).take(10).map( x => ++x ).publish().refCount(); | |
stream.subscribe( x => console.log(x) ); | |
//subscribe to the same stream 5 seconds later. | |
setTimeout( () => | |
stream.subscribe( x => console.log(x) ) | |
, 5000); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear() | |
var data = [1,2,3,4,5,6,7,8,9]; | |
var stream = Rx.Observable.interval(1000).take(10).map( x => ++x ).publish().refCount(); | |
stream.subscribe( x => console.log(x) ); | |
//subscribe to the same stream 5 seconds later. | |
setTimeout( () => | |
stream.subscribe( x => console.log(x) ) | |
, 5000); | |
</script></body> | |
</html> |
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
console.clear() | |
var data = [1,2,3,4,5,6,7,8,9]; | |
var stream = Rx.Observable.interval(1000).take(10).map( x => ++x ).publish().refCount(); | |
stream.subscribe( x => console.log(x) ); | |
//subscribe to the same stream 5 seconds later. | |
setTimeout( () => | |
stream.subscribe( x => console.log(x) ) | |
, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment