mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Add catch(console.error)
to all examples
Some examples have been failing to load in some browsers, and this ensures that whenever the promise to load Rust code fails we log any errors happening instead of accidentally failing silently. This helped debug a bit in #897
This commit is contained in:
@ -4,13 +4,15 @@ let imp = import('./char.js');
|
||||
let mod;
|
||||
|
||||
let counters = [];
|
||||
imp.then(wasm => {
|
||||
mod = wasm;
|
||||
addCounter();
|
||||
let b = document.getElementById('add-counter');
|
||||
if (!b) throw new Error('Unable to find #add-counter');
|
||||
b.addEventListener('click', ev => addCounter());
|
||||
});
|
||||
imp
|
||||
.then(wasm => {
|
||||
mod = wasm;
|
||||
addCounter();
|
||||
let b = document.getElementById('add-counter');
|
||||
if (!b) throw new Error('Unable to find #add-counter');
|
||||
b.addEventListener('click', ev => addCounter());
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
function addCounter() {
|
||||
let ctr = mod.Counter.new(randomChar(), 0);
|
||||
|
Reference in New Issue
Block a user