File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Top Open diff view settings
packages/sqlite_async/lib/src Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Top Open diff view settings Original file line number Diff line number Diff 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) {
You can’t perform that action at this time.
0 commit comments