Skip to content

Instantly share code, notes, and snippets.

@jfet97
Created February 6, 2020 09:11
Show Gist options
  • Save jfet97/5d8e4d740781bc3aa54e053d06eec27a to your computer and use it in GitHub Desktop.
Save jfet97/5d8e4d740781bc3aa54e053d06eec27a to your computer and use it in GitHub Desktop.
AsyncIterators RxJS
const ticker = interval(1000).pipe(take(100));
function snooze(ms) {
return new Promise(resolve => setTimeout(snooze, ms));
}
async function* values() {
for await (const number of ticker) {
await snooze(2000);
yield number;
}
}
from(values()).subscribe(x => console.log(x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment