@@ -143,7 +143,7 @@ class PowerSyncDatabaseImpl
143143 await isInitialized;
144144 final dbRef = database.isolateConnectionFactory ();
145145 ReceivePort rPort = ReceivePort ();
146- StreamSubscription ? updateSubscription ;
146+ StreamSubscription ? crudUpdateSubscription ;
147147 rPort.listen ((data) async {
148148 if (data is List ) {
149149 String action = data[0 ];
@@ -160,9 +160,9 @@ class PowerSyncDatabaseImpl
160160 });
161161 } else if (action == 'init' ) {
162162 SendPort port = data[1 ];
163- var throttled =
164- UpdateNotification . throttleStream (updates, crudThrottleTime);
165- updateSubscription = throttled .listen ((event) {
163+ var crudStream =
164+ database. onChange ([ 'ps_crud' ], throttle : crudThrottleTime);
165+ crudUpdateSubscription = crudStream .listen ((event) {
166166 port.send (['update' ]);
167167 });
168168 disconnector.onAbort.then ((_) {
@@ -179,7 +179,7 @@ class PowerSyncDatabaseImpl
179179 // Clear status apart from lastSyncedAt
180180 setStatus (SyncStatus (lastSyncedAt: currentStatus.lastSyncedAt));
181181 rPort.close ();
182- updateSubscription ? .cancel ();
182+ crudUpdateSubscription ? .cancel ();
183183 } else if (action == 'log' ) {
184184 LogRecord record = data[1 ];
185185 logger.log (
@@ -281,7 +281,7 @@ Future<void> _powerSyncDatabaseIsolate(
281281 _PowerSyncDatabaseIsolateArgs args) async {
282282 final sPort = args.sPort;
283283 ReceivePort rPort = ReceivePort ();
284- StreamController updateController = StreamController .broadcast ();
284+ StreamController < String > crudUpdateController = StreamController .broadcast ();
285285 final upstreamDbClient = args.dbRef.upstreamPort.open ();
286286
287287 CommonDatabase ? db;
@@ -292,14 +292,14 @@ Future<void> _powerSyncDatabaseIsolate(
292292 if (message is List ) {
293293 String action = message[0 ];
294294 if (action == 'update' ) {
295- updateController .add ('update' );
295+ crudUpdateController .add ('update' );
296296 } else if (action == 'close' ) {
297297 // The SyncSqliteConnection uses this mutex
298298 // It needs to be closed before killing the isolate
299299 // in order to free the mutex for other operations.
300300 await mutex.close ();
301301 db? .dispose ();
302- updateController .close ();
302+ crudUpdateController .close ();
303303 upstreamDbClient.close ();
304304 // Abort any open http requests, and wait for it to be closed properly
305305 await openedStreamingSync? .abort ();
@@ -349,7 +349,7 @@ Future<void> _powerSyncDatabaseIsolate(
349349 credentialsCallback: loadCredentials,
350350 invalidCredentialsCallback: invalidateCredentials,
351351 uploadCrud: uploadCrud,
352- updateStream : updateController .stream,
352+ crudUpdateTriggerStream : crudUpdateController .stream,
353353 retryDelay: args.retryDelay,
354354 client: http.Client (),
355355 syncParameters: args.parameters);
0 commit comments