Skip to content

Instantly share code, notes, and snippets.

@langley-agm
Forked from anonymous/index.html
Created February 22, 2016 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langley-agm/ebc0512581a19cf40e92 to your computer and use it in GitHub Desktop.
Save langley-agm/ebc0512581a19cf40e92 to your computer and use it in GitHub Desktop.
JS Bin RxJS Hot Observable // source https://jsbin.com/qazuse
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="RxJS Hot Observable">
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-alpha.8/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>
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