Skip to content

Instantly share code, notes, and snippets.

@shuding
Created January 22, 2016 07:50
Show Gist options
  • Save shuding/d0f3536249c153733a52 to your computer and use it in GitHub Desktop.
Save shuding/d0f3536249c153733a52 to your computer and use it in GitHub Desktop.
Counting
var y = count();
y.next();
function *count() {
yield setTimeout(() => { console.log(1); y.next(); }, 1000);
yield setTimeout(() => { console.log(2); y.next(); }, 1000);
yield setTimeout(() => { console.log(3); y.next(); }, 1000);
yield setTimeout(() => { console.log(4); y.next(); }, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment