Created
July 12, 2017 08:13
-
-
Save smorcuend/4908204ee444a3238bac13889137f286 to your computer and use it in GitHub Desktop.
JS Bin Simple RxJs Example // source https://jsbin.com/laxogo
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> | |
<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> |
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
"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