11import { Mutex } from 'async-mutex' ;
22import { EventIterator } from 'event-iterator' ;
33import Logger , { ILogger } from 'js-logger' ;
4- import throttle from 'lodash/throttle' ;
54import {
65 BatchedUpdateNotification ,
76 DBAdapter ,
@@ -16,6 +15,7 @@ import { Schema } from '../db/schema/Schema';
1615import { BaseObserver } from '../utils/BaseObserver' ;
1716import { ControlledExecutor } from '../utils/ControlledExecutor' ;
1817import { mutexRunExclusive } from '../utils/mutex' ;
18+ import { throttleTrailing } from '../utils/throttle.js' ;
1919import { SQLOpenFactory , SQLOpenOptions , isDBAdapter , isSQLOpenFactory , isSQLOpenOptions } from './SQLOpenFactory' ;
2020import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector' ;
2121import { BucketStorageAdapter , PSInternalTable } from './sync/bucket/BucketStorageAdapter' ;
@@ -898,14 +898,13 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
898898 await onChange ( e ) ;
899899 } ) ;
900900
901- const flushTableUpdates = throttle (
901+ const flushTableUpdates = throttleTrailing (
902902 ( ) =>
903903 this . handleTableChanges ( changedTables , watchedTables , ( intersection ) => {
904904 if ( resolvedOptions ?. signal ?. aborted ) return ;
905905 executor . schedule ( { changedTables : intersection } ) ;
906906 } ) ,
907- throttleMs ,
908- { leading : false , trailing : true }
907+ throttleMs
909908 ) ;
910909
911910 const dispose = this . database . registerListener ( {
0 commit comments