cpal/examples/wasm-beep/index.js

15 lines
448 B
JavaScript
Raw Permalink Normal View History

2020-03-01 01:59:48 +00:00
import("./pkg").catch(console.error).then(rust_module=>{
let handle = null;
const play_button = document.getElementById("play");
play_button.addEventListener("click", event => {
handle = rust_module.beep();
});
const stop_button = document.getElementById("stop");
stop_button.addEventListener("click", event => {
if (handle != null) {
handle.free();
handle = null;
}
});
});