Skip to content

Commit 6b36aa4

Browse files
committed
Changelog + OnChange test
1 parent 45bb4b6 commit 6b36aa4

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

PowerSync/PowerSync.Common/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 0.0.11-alpha.1
44

5+
- Implemented throttling for `Watch<T>` and `OnChange` (default 30ms).
56
- `StatusUpdated` and `StatusChanged` now both emit `SyncStatus` objects instead of just `StatusChanged`.
67
- Converted most instances of a class inheriting from `EventStream<T>` into a class with an `EventManager` property called `Events`. This allows for subscribing to individual events instead of subscribing to all events and then filtering events manually.
78

Tests/PowerSync/PowerSync.Common.Tests/Client/PowerSyncDatabaseTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,4 +1067,35 @@ public async Task Watch_SingleEventForBatchedQuery()
10671067
Assert.Equal(1, eventCount);
10681068
Assert.Equal(QUERY_COUNT, lastCount);
10691069
}
1070+
1071+
[Fact]
1072+
public async Task OnChange_SingleEventsForBatchedQuery()
1073+
{
1074+
int eventCount = 0;
1075+
var tcs = new TaskCompletionSource<bool>();
1076+
1077+
var listener = db.OnChange(new()
1078+
{
1079+
Tables = ["assets"],
1080+
Signal = testCts.Token,
1081+
});
1082+
1083+
_ = Task.Run(async () =>
1084+
{
1085+
await foreach (var _ in listener)
1086+
{
1087+
Interlocked.Increment(ref eventCount);
1088+
}
1089+
tcs.TrySetResult(true);
1090+
});
1091+
1092+
// Long batched query
1093+
const int QUERY_COUNT = 10000;
1094+
await TestUtils.InsertRandomAssets(db, QUERY_COUNT);
1095+
1096+
testCts.Cancel();
1097+
Assert.True(await tcs.Task);
1098+
1099+
Assert.Equal(1, eventCount);
1100+
}
10701101
}

0 commit comments

Comments
 (0)