You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This module exports a promise that loads and resolves to the actual sql.js module.
4
+
// In addition, When you use emcc's modularization, it still expects to export a global object called `Module`,
5
+
// which is able to be used/called before the WASM is loaded.
6
+
// The modularization below exports a promise that loads and resolves to the actual sql.js module.
5
7
// That way, this module can't be used before the WASM is finished loading.
6
8
7
-
8
-
// So the first thing that this module does is define a place for the loadedModule to reside
9
-
10
9
// We are going to define a function that a user will call to start loading initializing our Sql.js library
11
-
// However, that function might be called multiple times, and on subsequent calls, we want it to return the same module that it's already loaded once before.
10
+
// However, that function might be called multiple times, and on subsequent calls, we don't actually want it to instantiate a new instance of the Module
11
+
// Instead, we want to return the previously loaded module
12
12
13
+
// TODO: Make this not declare a global if used in the browser
13
14
var initSqlJsPromise = undefined;
14
15
15
16
var initSqlJs = function (moduleConfig) {
@@ -18,7 +19,7 @@ var initSqlJs = function (moduleConfig) {
18
19
return initSqlJsPromise;
19
20
}
20
21
// If we're here, we've never called this function before
21
-
initSqlJsPromise = new Promise((resolveModule) => {
22
+
initSqlJsPromise = new Promise((resolveModule, reject) => {
22
23
23
24
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// This module exports a promise that loads and resolves to the actual sql.js module.
4
+
// In addition, When you use emcc's modularization, it still expects to export a global object called `Module`,
5
+
// which is able to be used/called before the WASM is loaded.
6
+
// The modularization below exports a promise that loads and resolves to the actual sql.js module.
5
7
// That way, this module can't be used before the WASM is finished loading.
6
8
7
-
8
-
// So the first thing that this module does is define a place for the loadedModule to reside
9
-
10
9
// We are going to define a function that a user will call to start loading initializing our Sql.js library
11
-
// However, that function might be called multiple times, and on subsequent calls, we want it to return the same module that it's already loaded once before.
10
+
// However, that function might be called multiple times, and on subsequent calls, we don't actually want it to instantiate a new instance of the Module
11
+
// Instead, we want to return the previously loaded module
12
12
13
+
// TODO: Make this not declare a global if used in the browser
13
14
varinitSqlJsPromise=undefined;
14
15
15
16
varinitSqlJs=function(moduleConfig){
@@ -18,7 +19,7 @@ var initSqlJs = function (moduleConfig) {
18
19
returninitSqlJsPromise;
19
20
}
20
21
// If we're here, we've never called this function before
0 commit comments