The WasmLoader is a utility module for loading and managing WebAssembly modules in your Saito application. It provides:
const WasmLoader = require("../../lib/helpers/wasmLoader");
Generate or provide the import object required by your WASM module:
const importObject = {
env: {
memory: new WebAssembly.Memory({ initial: 256 })
// ... other imports
}
};
// Load module
onPeerHandshakeComplete(){
const loader = new WasmLoader(app, mod);
const instance = await loader.loadWasm('file_name.wasm', importObject);
// Execute functions
const result = instance.exports.yourFunction();
}
// Clear specific instance
loader.clearInstance('file_name.wasm');
// Clear all instances
loader.clearAllInstances();