You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking: perhaps it would make sense to register modules directly?
E.g. turn this:
varrust=require('rustify')varwasm=rust`#[no_mangle]pubfnadd_one(x:i32) -> i32{ x + 1}`WebAssembly.instantiate(wasm,{}).then(function(res){varaddOne=res.instance.exports.add_oneconsole.log(addOne(41))console.log(addOne(68))}).catch(function(e){console.error('Creating WASM module failed',e)})
Into this:
varrust=require('rustify')varwasm=rust`#[no_mangle]pubfnadd_one(x:i32) -> i32{ x + 1}`wasm.then((mod)=>{console.log(mod.add_one(41))console.log(mod.add_one(68))}).catch((e)=>console.error('WASM error',e))
The benefit is that there's way less code to remember (ugh, res.instance.exports). The downside is that we're no long just exposing a Uint8Array, so doing things like registering a function twice is not going to be possible.
Would this be worth it?
The text was updated successfully, but these errors were encountered:
I was thinking: perhaps it would make sense to register modules directly?
E.g. turn this:
Into this:
The benefit is that there's way less code to remember (ugh,
res.instance.exports
). The downside is that we're no long just exposing a Uint8Array, so doing things like registering a function twice is not going to be possible.Would this be worth it?
The text was updated successfully, but these errors were encountered: