Skip to content

Commit fbb7cb4

Browse files
DominicGBauerDominicGBauer
andauthored
chore: add crud throttle option (#71)
* chore(powersync): add crud throttle to connect * chore(powersync): add crud throttle to connect --------- Co-authored-by: DominicGBauer <dominic@nomanini.com>
1 parent 242636f commit fbb7cb4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

demos/supabase-todolist/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,10 @@ packages:
551551
dependency: "direct main"
552552
description:
553553
name: sqlite_async
554-
sha256: "609a8405b8b608ac396dd7f478ed42e230c496eb38fe53dd97e9c592e1cd5cda"
554+
sha256: "139c8f1085132d0941b925efacb4fa0fed9ee40d624739cc26a051dbc36bf727"
555555
url: "https://pub.dev"
556556
source: hosted
557-
version: "0.6.0"
557+
version: "0.6.1"
558558
stack_trace:
559559
dependency: transitive
560560
description:

packages/powersync/lib/src/powersync_database.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
184184
/// The connection is automatically re-opened if it fails for any reason.
185185
///
186186
/// Status changes are reported on [statusStream].
187-
Future<void> connect({required PowerSyncBackendConnector connector}) async {
187+
Future<void> connect(
188+
{required PowerSyncBackendConnector connector,
189+
190+
/// Throttle time between CRUD operations
191+
/// Defaults to 10 milliseconds.
192+
Duration crudThrottleTime = const Duration(milliseconds: 10)}) async {
188193
await initialize();
189194

190195
// Disconnect if connected
@@ -212,8 +217,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
212217
});
213218
} else if (action == 'init') {
214219
SendPort port = data[1];
215-
var throttled = UpdateNotification.throttleStream(
216-
updates, const Duration(milliseconds: 10));
220+
var throttled =
221+
UpdateNotification.throttleStream(updates, crudThrottleTime);
217222
updateSubscription = throttled.listen((event) {
218223
port.send(['update']);
219224
});

0 commit comments

Comments
 (0)