Skip to content

Instantly share code, notes, and snippets.

@shugo
Last active December 17, 2022 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shugo/072b03d4bc3ed31b7e71e0a131c1d36d to your computer and use it in GitHub Desktop.
Save shugo/072b03d4bc3ed31b7e71e0a131c1d36d to your computer and use it in GitHub Desktop.
<html>
<script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@0.5.0/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