Skip to content

Commit 8462470

Browse files
committed
Review feedback
1 parent 7091faf commit 8462470

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/sqlite_async/lib/src/update_notification.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,32 @@ Stream<T> _throttleStream<T extends Object>({
114114
}
115115
}
116116

117+
late void Function() setTimeout;
118+
117119
/// Emits [pendingData] if no timeout window is active, and then starts a
118120
/// timeout window if necessary.
119121
void maybeEmit() {
120122
if (activeTimeoutWindow == null && !listener.isPaused) {
121123
final didAdd = addPendingEvents();
122124
if (didAdd) {
125+
// Schedule a pause after resume if the subscription was paused
126+
// directly in response to receiving the event. Otherwise, begin the
127+
// timeout window immediately.
123128
if (listener.isPaused) {
124129
needsTimeoutWindowAfterResume = true;
125130
} else {
126-
activeTimeoutWindow = Timer(timeout, () {
127-
activeTimeoutWindow = null;
128-
maybeEmit();
129-
});
131+
setTimeout();
130132
}
131133
}
132134
}
133135
}
134136

135-
void setTimeout() {
137+
setTimeout = () {
136138
activeTimeoutWindow = Timer(timeout, () {
137139
activeTimeoutWindow = null;
138140
maybeEmit();
139141
});
140-
}
142+
};
141143

142144
void onData(T data) {
143145
pendingData = switch (pendingData) {

0 commit comments

Comments
 (0)