Skip to content

Commit f78173f

Browse files
committed
Improve some API names
1 parent 82bfa80 commit f78173f

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

packages/powersync_core/lib/src/sync/connection_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ final class _SyncStreamSubscriptionHandle implements SyncStreamSubscription {
380380
@override
381381
Future<void> waitForFirstSync() async {
382382
return _source.connections.firstStatusMatching((status) {
383-
final currentProgress = status.statusFor(this);
383+
final currentProgress = status.forStream(this);
384384
return currentProgress?.subscription.hasSynced ?? false;
385385
});
386386
}

packages/powersync_core/lib/src/sync/sync_status.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ final class SyncStatus {
117117
);
118118
}
119119

120-
/// All sync streams currently being tracked in this subscription.
120+
/// All sync streams currently being tracked in the database.
121121
///
122122
/// This returns null when the database is currently being opened and we
123123
/// don't have reliable information about all included streams yet.
124-
Iterable<SyncStreamStatus>? get subscriptions {
124+
Iterable<SyncStreamStatus>? get syncStreams {
125125
return _internalSubscriptions?.map((subscription) {
126126
return SyncStreamStatus._(subscription, downloadProgress);
127127
});
@@ -166,9 +166,9 @@ final class SyncStatus {
166166
);
167167
}
168168

169-
/// If the [stream] appears in [activeSubscriptions], returns the current
170-
/// status for that stream.
171-
SyncStreamStatus? statusFor(SyncStreamDescription stream) {
169+
/// If the [stream] appears in [syncStreams], returns the current status for
170+
/// that stream.
171+
SyncStreamStatus? forStream(SyncStreamDescription stream) {
172172
final raw = _internalSubscriptions?.firstWhereOrNull(
173173
(e) =>
174174
e.name == stream.name &&

packages/powersync_core/test/sync/stream_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ void main() {
142142

143143
var status = await statusStream.next;
144144
for (final subscription in [a, b]) {
145-
expect(status.statusFor(subscription)!.subscription.active, true);
146-
expect(status.statusFor(subscription)!.subscription.lastSyncedAt, isNull);
145+
expect(status.forStream(subscription)!.subscription.active, true);
146+
expect(status.forStream(subscription)!.subscription.lastSyncedAt, isNull);
147147
expect(
148-
status.statusFor(subscription)!.subscription.hasExplicitSubscription,
148+
status.forStream(subscription)!.subscription.hasExplicitSubscription,
149149
true,
150150
);
151151
}
152152

153153
syncService.addLine(checkpointComplete(priority: 1));
154154
status = await statusStream.next;
155-
expect(status.statusFor(a)!.subscription.lastSyncedAt, isNull);
156-
expect(status.statusFor(b)!.subscription.lastSyncedAt, isNotNull);
155+
expect(status.forStream(a)!.subscription.lastSyncedAt, isNull);
156+
expect(status.forStream(b)!.subscription.lastSyncedAt, isNotNull);
157157
await b.waitForFirstSync();
158158

159159
syncService.addLine(checkpointComplete());
@@ -170,7 +170,7 @@ void main() {
170170
status,
171171
emits(
172172
isSyncStatus(
173-
subscriptions: [
173+
syncStreams: [
174174
isStreamStatus(
175175
subscription: isSyncSubscription(
176176
name: 'default_stream',
@@ -217,6 +217,6 @@ void main() {
217217

218218
final subscription = await database.syncStream('foo').subscribe();
219219
var status = await stream.next;
220-
expect(status.statusFor(subscription), isNotNull);
220+
expect(status.forStream(subscription), isNotNull);
221221
});
222222
}

packages/powersync_core/test/sync/utils.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TypeMatcher<SyncStatus> isSyncStatus({
88
Object? connecting,
99
Object? hasSynced,
1010
Object? downloadProgress,
11-
Object? subscriptions,
11+
Object? syncStreams,
1212
}) {
1313
var matcher = isA<SyncStatus>();
1414
if (downloading != null) {
@@ -27,9 +27,8 @@ TypeMatcher<SyncStatus> isSyncStatus({
2727
matcher = matcher.having(
2828
(e) => e.downloadProgress, 'downloadProgress', downloadProgress);
2929
}
30-
if (subscriptions != null) {
31-
matcher =
32-
matcher.having((e) => e.subscriptions, 'subscriptions', subscriptions);
30+
if (syncStreams != null) {
31+
matcher = matcher.having((e) => e.syncStreams, 'syncStreams', syncStreams);
3332
}
3433

3534
return matcher;

0 commit comments

Comments
 (0)