Skip to content

Commit 9d71ebf

Browse files
perf(rxdart_flutter): optimize ValueStreamListener stream skipping
Improve stream skipping logic in ValueStreamListener by: - Conditionally applying skip only when skipCount is greater than 0 - Simplify stream listening mechanism
1 parent 6ac813c commit 9d71ebf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/rxdart_flutter/lib/src/value_stream_listener.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ class _ValueStreamListenerState<T> extends State<ValueStreamListener<T>> {
140140
}
141141
}
142142

143-
_subscription = stream.skip(skipCount).listen(
143+
final streamToListen = skipCount > 0 ? stream.skip(skipCount) : stream;
144+
145+
_subscription = streamToListen.listen(
144146
(value) {
145147
if (!mounted) return;
146148
_notifyListener(value);

0 commit comments

Comments
 (0)