Hi all!

I'm documenting a recent change in the semantics of Emscripten and emcc
(starting from 1.39.x and also seems to affect 2.0.x): Module() now returns a
promise and one should for example do:

Module().then((result) => {
        real_module = result;
})

E.g like in
https://github.com/shlomif/fc-solve/commit/dcdb924262860eb8d023402400fa1e8cd9dce6c2
:

diff --git a/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
b/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts index f3082e52f..d510bc4fa
100644 --- a/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
+++ b/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
@@ -494,7 +494,12 @@ export function test_js_fc_solve_class(qunit: QUnit,
my_callback: () => void) { // var _my_mod = Module({});
     const _my_mod = [null];
     _my_mod[0] = Module()({
-        onRuntimeInitialized: my_func(qunit, _my_mod, my_callback),
+        onRuntimeInitialized: () => {
+            _my_mod[0].then((result) => {
+                _my_mod[0] = result;
+                return my_func(qunit, _my_mod, my_callback)();
+            });
+        },
     });
     return;
 }

(my code has a little weirdness of using "Module()()" instead of "Module()" -
you can ignore that).

For more about js promises, see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

-- 

Shlomi Fish       https://www.shlomifish.org/
Perl Elems to Avoid - https://perl-begin.org/tutorials/bad-elements/

There was one Napoleon, one George Washington, and one me!
    — Big Boy Caprice in
       https://en.wikiquote.org/wiki/Dick_Tracy_%281990_film%29

Please reply to list if it's a mailing list post - https://shlom.in/reply .

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/20200821152439.0cb14ca2%40telaviv1.shlomifish.org.

Reply via email to