Add wasm-beep example
This commit is contained in:
parent
cf4e6ca5bf
commit
9dc0c04c95
10 changed files with 6938 additions and 0 deletions
14
examples/wasm-beep/index.js
Normal file
14
examples/wasm-beep/index.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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;
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue