connect method
Future<void>
connect({
- required PowerSyncBackendConnector connector,
- Duration crudThrottleTime = const Duration(milliseconds: 10),
- 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.
Status changes are reported on statusStream
.
Implementation
Future<void> connect(
{required PowerSyncBackendConnector connector,
/// Throttle time between CRUD operations
/// Defaults to 10 milliseconds.
Duration crudThrottleTime = const Duration(milliseconds: 10),
Map<String, dynamic>? params}) async {
clientParams = params;
Zone current = Zone.current;
Future<void> reconnect() {
return _connectMutex.lock(() => baseConnect(
connector: connector,
crudThrottleTime: crudThrottleTime,
// The reconnect function needs to run in the original zone,
// to avoid recursive lock errors.
reconnect: current.bindCallback(reconnect),
params: params));
}
await reconnect();
}