.DS_Store
# save-time-avoiding-common-mistakes-using-rxjs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div></div>
<script src="https://unpkg.com/rxjs@5.4.3/bundles/Rx.min.js"></script>
<script src="script.js"></script>
</body>
</html>
const clock$ = Rx.Observable.interval(500).share().take(6);
const randomNum$ = clock$
.map(i => Math.random() * 100).share();
const smallNum$ = randomNum$
.filter(x => x <= 50)
.toArray();
const largeNum$ = randomNum$
.filter(x => x > 50)
.toArray();
randomNum$.subscribe(x => console.log('random: ' + x) || displayInPreview('random: ' + x));
smallNum$.subscribe(x => console.log('small:', x) || displayInPreview('small:' + x));
largeNum$.subscribe(x => console.log('large:', x) || displayInPreview('large:' + x));
// display in plunker preview
function displayInPreview(string) {
var newDiv = document.createElement("div");
var newContent = document.createTextNode(string);
newDiv.appendChild(newContent);
document.body.appendChild(newDiv)
}