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 (!context.hasProperty('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(promiseToFuture<_SqlJs>(_initSqlJs()).then(SqlJsModule._));
  }

  return _moduleCompleter!.future;
}