fromModuleAsync static method

Future<Instance> fromModuleAsync(
  1. Module module, {
  2. Map<String, Map<String, Object>>? importMap,
  3. Object? importObject,
})

Asynchronously instantiates compiled WebAssembly Module with imports.

See Instance.fromModule regarding importMap and importObject usage.

Implementation

static Future<Instance> fromModuleAsync(Module module,
        {Map<String, Map<String, Object>>? importMap,
        Object? importObject}) =>
    promiseToFuture<_Instance>(_instantiateModule(
            module.jsObject, _reifyImports(importMap, importObject)))
        .then((_instance) => Instance._(_instance, module))
        .catchError((Object e) {
      if (instanceof(e, _compileError)) {
        throw CompileError(getProperty(e, 'message'));
      } else if (instanceof(e, _linkError)) {
        throw LinkError(getProperty(e, 'message'));
      } else if (instanceof(e, _runtimeError)) {
        throw RuntimeError(getProperty(e, 'message'));
      }
      // ignore: only_throw_errors
      throw e;
    });