loadModule method

Future<Instance> loadModule(
  1. Response response
)

Load and instantiate a WebAssembly module from a fetch response by providing host imports.

Returns a WebAssembly.Instance JavaScript object.

Implementation

Future<web.Instance> loadModule(web.Response response) async {
  final module = await instantiateModule(response);

  // If the module has an `_initialize` export, it needs to be called to run
  // C constructors and set up memory.
  final exports = module.instance.exports;
  if (exports.has('_initialize')) {
    (exports['_initialize'] as JSFunction).callAsFunction();
  }

  return module.instance;
}