-
-
Save seanreed1111/d4c083acb77c62a670203cfc7f426a01 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/zoqito
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 charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://unpkg.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script> | |
<button id="start">Start</button> | |
<button id="stop">Stop</button> | |
<script id="jsbin-javascript"> | |
const Observable = Rx.Observable; | |
const startButton = document.querySelector('#start'); | |
const stopButton = document.querySelector('#stop'); | |
const start$ = Observable.fromEvent(startButton, 'click'); | |
const stop$ = Observable.fromEvent(stopButton, 'click'); | |
const interval$ = Observable.interval(1000); | |
start$ | |
.switchMapTo(interval$) | |
.takeUntil(stop$) | |
.subscribe((x)=> console.log(x)); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const Observable = Rx.Observable; | |
const startButton = document.querySelector('#start'); | |
const stopButton = document.querySelector('#stop'); | |
const start$ = Observable.fromEvent(startButton, 'click'); | |
const stop$ = Observable.fromEvent(stopButton, 'click'); | |
const interval$ = Observable.interval(1000); | |
start$ | |
.switchMapTo(interval$) | |
.takeUntil(stop$) | |
.subscribe((x)=> console.log(x)); | |
</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
const Observable = Rx.Observable; | |
const startButton = document.querySelector('#start'); | |
const stopButton = document.querySelector('#stop'); | |
const start$ = Observable.fromEvent(startButton, 'click'); | |
const stop$ = Observable.fromEvent(stopButton, 'click'); | |
const interval$ = Observable.interval(1000); | |
start$ | |
.switchMapTo(interval$) | |
.takeUntil(stop$) | |
.subscribe((x)=> console.log(x)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First use of Observables. Huzzah!