initSqlJs function

Future<SqlJsModule> initSqlJs()

Calls the initSqlJs function from the native sql.js library.

Implementation

Future<SqlJsModule> initSqlJs() {
  if (_moduleCompleter != null) {
    return _moduleCompleter!.future;
  }

  final completer = _moduleCompleter = Completer();
  if (!globalContext.has('initSqlJs')) {
    completer.completeError(UnsupportedError(
        'Could not access the sql.js javascript library. '
        'The drift documentation contains instructions on how to setup drift '
        'the web, which might help you fix this.'));
  } else {
    completer.complete((_initSqlJs().toDart).then(SqlJsModule._));
  }

  return _moduleCompleter!.future;
}