Created
August 23, 2017 01:06
-
-
Save benlesh/6ea17efa795b1b40820c0fba004d4c84 to your computer and use it in GitHub Desktop.
This file contains 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 click$ = Observable.fromEvent(button, 'clicks'); | |
/** | |
* Waits for 10 clicks of the button | |
* then posts a timestamp of the tenth click to an endpoint | |
* using fetch | |
*/ | |
async function doWork() { | |
await click$.take(10) | |
.forEach((_, i) => console.log(`click ${i + 1}`)); | |
return await fetch( | |
'notify/tenclicks', | |
{ method: 'POST', body: Date.now() } | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment