File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
packages/sqlite_async/lib/src Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -114,30 +114,32 @@ Stream<T> _throttleStream<T extends Object>({
114
114
}
115
115
}
116
116
117
+ late void Function () setTimeout;
118
+
117
119
/// Emits [pendingData] if no timeout window is active, and then starts a
118
120
/// timeout window if necessary.
119
121
void maybeEmit () {
120
122
if (activeTimeoutWindow == null && ! listener.isPaused) {
121
123
final didAdd = addPendingEvents ();
122
124
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.
123
128
if (listener.isPaused) {
124
129
needsTimeoutWindowAfterResume = true ;
125
130
} else {
126
- activeTimeoutWindow = Timer (timeout, () {
127
- activeTimeoutWindow = null ;
128
- maybeEmit ();
129
- });
131
+ setTimeout ();
130
132
}
131
133
}
132
134
}
133
135
}
134
136
135
- void setTimeout () {
137
+ setTimeout = () {
136
138
activeTimeoutWindow = Timer (timeout, () {
137
139
activeTimeoutWindow = null ;
138
140
maybeEmit ();
139
141
});
140
- }
142
+ };
141
143
142
144
void onData (T data) {
143
145
pendingData = switch (pendingData) {
You can’t perform that action at this time.
0 commit comments