@@ -77,6 +77,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
7777 /// Use [attachedLogger] to propagate logs to [Logger.root] for custom logging.
7878 late final Logger logger;
7979
80+ Map <String , dynamic >? clientParams;
81+
8082 /// Open a [PowerSyncDatabase] .
8183 ///
8284 /// Only a single [PowerSyncDatabase] per [path] should be opened at a time.
@@ -219,7 +221,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
219221
220222 /// Throttle time between CRUD operations
221223 /// 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 {
223226 Zone current = Zone .current;
224227
225228 Future <void > reconnect () {
@@ -228,7 +231,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
228231 crudThrottleTime: crudThrottleTime,
229232 // The reconnect function needs to run in the original zone,
230233 // to avoid recursive lock errors.
231- reconnect: current.bindCallback (reconnect)));
234+ reconnect: current.bindCallback (reconnect),
235+ params: params));
232236 }
233237
234238 await reconnect ();
@@ -237,7 +241,9 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
237241 Future <void > _connect (
238242 {required PowerSyncBackendConnector connector,
239243 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;
241247 await initialize ();
242248
243249 // Disconnect if connected
@@ -330,8 +336,10 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
330336 return ;
331337 }
332338
333- Isolate .spawn (_powerSyncDatabaseIsolate,
334- _PowerSyncDatabaseIsolateArgs (rPort.sendPort, dbref, retryDelay),
339+ Isolate .spawn (
340+ _powerSyncDatabaseIsolate,
341+ _PowerSyncDatabaseIsolateArgs (
342+ rPort.sendPort, dbref, retryDelay, clientParams),
335343 debugName: 'PowerSyncDatabase' ,
336344 onError: errorPort.sendPort,
337345 onExit: exitPort.sendPort);
@@ -562,8 +570,10 @@ class _PowerSyncDatabaseIsolateArgs {
562570 final SendPort sPort;
563571 final IsolateConnectionFactory dbRef;
564572 final Duration retryDelay;
573+ final Map <String , dynamic >? parameters;
565574
566- _PowerSyncDatabaseIsolateArgs (this .sPort, this .dbRef, this .retryDelay);
575+ _PowerSyncDatabaseIsolateArgs (
576+ this .sPort, this .dbRef, this .retryDelay, this .parameters);
567577}
568578
569579Future <void > _powerSyncDatabaseIsolate (
@@ -638,7 +648,9 @@ Future<void> _powerSyncDatabaseIsolate(
638648 invalidCredentialsCallback: invalidateCredentials,
639649 uploadCrud: uploadCrud,
640650 updateStream: updateController.stream,
641- retryDelay: args.retryDelay);
651+ retryDelay: args.retryDelay,
652+ syncParameters: args.parameters);
653+
642654 openedStreamingSync = sync ;
643655 sync .streamingSync ();
644656 sync .statusStream.listen ((event) {
0 commit comments