@@ -77,6 +77,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
77
77
/// Use [attachedLogger] to propagate logs to [Logger.root] for custom logging.
78
78
late final Logger logger;
79
79
80
+ Map <String , dynamic >? clientParams;
81
+
80
82
/// Open a [PowerSyncDatabase] .
81
83
///
82
84
/// Only a single [PowerSyncDatabase] per [path] should be opened at a time.
@@ -219,7 +221,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
219
221
220
222
/// Throttle time between CRUD operations
221
223
/// Defaults to 10 milliseconds.
222
- Duration crudThrottleTime = const Duration (milliseconds: 10 )}) async {
224
+ Duration crudThrottleTime = const Duration (milliseconds: 10 ),
225
+ Map <String , dynamic >? params}) async {
223
226
Zone current = Zone .current;
224
227
225
228
Future <void > reconnect () {
@@ -228,7 +231,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
228
231
crudThrottleTime: crudThrottleTime,
229
232
// The reconnect function needs to run in the original zone,
230
233
// to avoid recursive lock errors.
231
- reconnect: current.bindCallback (reconnect)));
234
+ reconnect: current.bindCallback (reconnect),
235
+ params: params));
232
236
}
233
237
234
238
await reconnect ();
@@ -237,7 +241,9 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
237
241
Future <void > _connect (
238
242
{required PowerSyncBackendConnector connector,
239
243
required Duration crudThrottleTime,
240
- required Future <void > Function () reconnect}) async {
244
+ required Future <void > Function () reconnect,
245
+ Map <String , dynamic >? params}) async {
246
+ clientParams = params;
241
247
await initialize ();
242
248
243
249
// Disconnect if connected
@@ -330,8 +336,10 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
330
336
return ;
331
337
}
332
338
333
- Isolate .spawn (_powerSyncDatabaseIsolate,
334
- _PowerSyncDatabaseIsolateArgs (rPort.sendPort, dbref, retryDelay),
339
+ Isolate .spawn (
340
+ _powerSyncDatabaseIsolate,
341
+ _PowerSyncDatabaseIsolateArgs (
342
+ rPort.sendPort, dbref, retryDelay, clientParams),
335
343
debugName: 'PowerSyncDatabase' ,
336
344
onError: errorPort.sendPort,
337
345
onExit: exitPort.sendPort);
@@ -562,8 +570,10 @@ class _PowerSyncDatabaseIsolateArgs {
562
570
final SendPort sPort;
563
571
final IsolateConnectionFactory dbRef;
564
572
final Duration retryDelay;
573
+ final Map <String , dynamic >? parameters;
565
574
566
- _PowerSyncDatabaseIsolateArgs (this .sPort, this .dbRef, this .retryDelay);
575
+ _PowerSyncDatabaseIsolateArgs (
576
+ this .sPort, this .dbRef, this .retryDelay, this .parameters);
567
577
}
568
578
569
579
Future <void > _powerSyncDatabaseIsolate (
@@ -638,7 +648,9 @@ Future<void> _powerSyncDatabaseIsolate(
638
648
invalidCredentialsCallback: invalidateCredentials,
639
649
uploadCrud: uploadCrud,
640
650
updateStream: updateController.stream,
641
- retryDelay: args.retryDelay);
651
+ retryDelay: args.retryDelay,
652
+ syncParameters: args.parameters);
653
+
642
654
openedStreamingSync = sync ;
643
655
sync .streamingSync ();
644
656
sync .statusStream.listen ((event) {
0 commit comments