Kevin Lubick | 65846c0 | 2019-01-04 14:16:19 -0500 | [diff] [blame] | 1 | // See https://github.com/kripken/emscripten/issues/5820#issuecomment-385722568 |
| 2 | // for context on why the .then() that comes with Module breaks things (e.g. infinite loops) |
| 3 | // and why the below fixes it. |
| 4 | Module['ready'] = function() { |
| 5 | return new Promise(function (resolve, reject) { |
Kevin Lubick | 65846c0 | 2019-01-04 14:16:19 -0500 | [diff] [blame] | 6 | Module['onAbort'] = reject; |
Kevin Lubick | faa7387 | 2019-01-06 22:27:54 -0500 | [diff] [blame] | 7 | if (runtimeInitialized) { |
| 8 | resolve(Module); |
| 9 | } else { |
| 10 | addOnPostRun(function() { |
| 11 | resolve(Module); |
| 12 | }); |
| 13 | } |
Kevin Lubick | 65846c0 | 2019-01-04 14:16:19 -0500 | [diff] [blame] | 14 | }); |
| 15 | } |
Kevin Lubick | 2722083 | 2019-02-25 16:04:02 -0500 | [diff] [blame] | 16 | delete Module['then']; |