connect method

Future<void> connect({
  1. required PowerSyncBackendConnector connector,
  2. SyncOptions? options,
  3. @Deprecated('Use SyncOptions.crudThrottleTime instead') Duration? crudThrottleTime,
  4. Map<String, dynamic>? params,
})
inherited

Connect to the PowerSync service, and keep the databases in sync.

The connection is automatically re-opened if it fails for any reason.

To set sync parameters used in your sync rules (if any), use SyncOptions.params. SyncOptions can also be used to tune the behavior of the sync client, see that class for more information.

Status changes are reported on statusStream.

Implementation

Future<void> connect({
  required PowerSyncBackendConnector connector,
  SyncOptions? options,
  @Deprecated('Use SyncOptions.crudThrottleTime instead')
  Duration? crudThrottleTime,
  Map<String, dynamic>? params,
}) async {
  // The initialization process acquires a sync connect lock (through
  // updateSchema), so ensure the database is ready before we try to acquire
  // the lock for the connection.
  await initialize();

  final resolvedOptions = ResolvedSyncOptions.resolve(
    options,
    crudThrottleTime: crudThrottleTime,
    // ignore: deprecated_member_use_from_same_package
    retryDelay: retryDelay,
    params: params,
  );

  await _connections.connect(connector: connector, options: resolvedOptions);
}