Created
December 11, 2017 09:43
-
-
Save jooyunghan/81c1af21897d77f93630f04fb89c6e44 to your computer and use it in GitHub Desktop.
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
| function success() { | |
| run(showToast("pass")); | |
| } | |
| function* showToast(message) { | |
| var div = document.createElement("div"); | |
| div.className = "toast in"; | |
| div.textContent = message; | |
| document.body.appendChild(div); | |
| yield delay(1000); | |
| div.className = "toast out"; | |
| yield delay(500); | |
| document.body.removeChild(div); | |
| } | |
| function run(g) { | |
| const { value, done } = g.next(); | |
| if (!done) { | |
| value.then(() => run(g)); | |
| } | |
| } | |
| function delay(ms) { | |
| return new Promise(r => setTimeout(r, ms)); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment