baseInit method

  1. @protected
Future<void> baseInit()
inherited

Implementation

@protected
Future<void> baseInit() async {
  String identifier = 'memory';
  try {
    identifier = database.openFactory.path;
  } catch (ignore) {
    // The in-memory database used in some tests doesn't have an open factory.
  }

  _activeGroup = ActiveDatabaseGroup.referenceDatabase(identifier);
  if (_activeGroup.refCount > 1) {
    logger.warning(
      'Multiple instances for the same database have been detected. '
      'This can cause unexpected results, please check your PowerSync client '
      'instantiation logic if this is not intentional',
    );
  }

  statusStream = statusStreamController.stream;
  updates = powerSyncUpdateNotifications(database.updates);

  await database.initialize();
  await _checkVersion();
  await database.execute('SELECT powersync_init()');
  await updateSchema(schema);
  await _updateHasSynced();
}