Last active
December 17, 2022 00:06
-
-
Save shugo/072b03d4bc3ed31b7e71e0a131c1d36d 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
<html> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser.script.iife.js"></script> | |
<script type="text/ruby"> | |
require "js" | |
document = JS.global[:document] | |
window = JS.global[:window] | |
start = document.getElementById("start") | |
counter = document.getElementById("counter") | |
start.addEventListener("click") do |e| | |
10.times do |i| | |
p i | |
counter[:innerText] = i.to_s | |
p JS.eval('return new Promise((ok) => setTimeout(ok(42), 1000))').await | |
end | |
end | |
</script> | |
<button id="start">Start</button> | |
<div id="counter">0</div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment