Skip to content

Commit

Permalink
Revert record change, but make ctor public (per discussion)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed Aug 16, 2023
1 parent 33fd652 commit 5de22ad
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/src/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,18 @@ class Session implements Finalizable {
}

/// A type containing information about the progress state at a given instant.
typedef SyncProgress = ({
class SyncProgress {
/// The number of bytes that have been transferred since subscribing for progress notifications.
int transferredBytes,
final int transferredBytes;

/// The total number of bytes that have to be transferred since subscribing for progress notifications.
/// The difference between that number and [transferredBytes] gives you the number of bytes not yet
/// transferred. If the difference is 0, then all changes at the instant the callback fires have been
/// successfully transferred.
int transferableBytes,
});
final int transferableBytes;

const SyncProgress({required this.transferredBytes, required this.transferableBytes});
}

/// A type containing information about the transition of a connection state from one value to another.
class ConnectionStateChange {
Expand Down Expand Up @@ -124,7 +126,7 @@ extension SessionInternal on Session {
}

static SyncProgress createSyncProgress(int transferredBytes, int transferableBytes) =>
(transferredBytes: transferredBytes, transferableBytes: transferableBytes);
SyncProgress(transferredBytes: transferredBytes, transferableBytes: transferableBytes);
}

abstract interface class ProgressNotificationsController {
Expand All @@ -149,7 +151,7 @@ class SessionProgressNotificationsController implements ProgressNotificationsCon

@override
void onProgress(int transferredBytes, int transferableBytes) {
_streamController.add((transferredBytes: transferredBytes, transferableBytes: transferableBytes));
_streamController.add(SyncProgress(transferredBytes: transferredBytes, transferableBytes: transferableBytes));

if (transferredBytes >= transferableBytes && _mode == ProgressMode.forCurrentlyOutstandingWork) {
_streamController.close();
Expand Down

0 comments on commit 5de22ad

Please sign in to comment.