Skip to content

Instantly share code, notes, and snippets.

@smorcuend
Created July 12, 2017 08:13
Show Gist options
  • Save smorcuend/4908204ee444a3238bac13889137f286 to your computer and use it in GitHub Desktop.
Save smorcuend/4908204ee444a3238bac13889137f286 to your computer and use it in GitHub Desktop.
JS Bin Simple RxJs Example // source https://jsbin.com/laxogo
<!DOCTYPE html>
<html>
<head>
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script>
<meta name="description" content="Simple RxJs Example">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
"use strict";
var obs = Rx.Observable.interval(500).take(5)["do"](function (i) {
return console.log("obs value " + i);
}).share();
obs.subscribe(function (value) {
return console.log("observer 1 received " + value);
});
obs.subscribe(function (value) {
return console.log("observer 2 received " + value);
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">var obs = Rx.Observable.interval(500).take(5)
.do(i => console.log("obs value "+ i) )
.share();
obs.subscribe(value => console.log("observer 1 received " + value));
obs.subscribe(value => console.log("observer 2 received " + value));
</script></body>
</html>
"use strict";
var obs = Rx.Observable.interval(500).take(5)["do"](function (i) {
return console.log("obs value " + i);
}).share();
obs.subscribe(function (value) {
return console.log("observer 1 received " + value);
});
obs.subscribe(function (value) {
return console.log("observer 2 received " + value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment