W3cubDocs

/Dart 2

open method

Future<Database> open (String name, { int version, void onUpgradeNeeded(VersionChangeEvent event), void onBlocked(Event event) })

Implementation

Future<Database> open(String name,
    {int version,
    void onUpgradeNeeded(VersionChangeEvent event),
    void onBlocked(Event event)}) {
  if ((version == null) != (onUpgradeNeeded == null)) {
    return new Future.error(new ArgumentError(
        'version and onUpgradeNeeded must be specified together'));
  }
  try {
    var request;
    if (version != null) {
      request = _open(name, version);
    } else {
      request = _open(name);
    }

    if (onUpgradeNeeded != null) {
      request.onUpgradeNeeded.listen(onUpgradeNeeded);
    }
    if (onBlocked != null) {
      request.onBlocked.listen(onBlocked);
    }
    return _completeRequest(request);
  } catch (e, stacktrace) {
    return new Future.error(e, stacktrace);
  }
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-indexed_db/IdbFactory/open.html