You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d2c791d
Browse filesBrowse the repository at this point in the historyBrowse files
Make FromEventBuffered's bufferSize nullable, defaulting to unbounded
The 0.1.3 fallout: FromEventBuffered's own default of 1 was an arbitrary opinion this
wrapper had no business holding, and it was wrong for the wrapper's actual dominant use
case (filtering for a specific match among payloads that could arrive in the
pre-subscribe gap this method exists to cover) - even I fell into it myself, in
puppeteer-sharp's own WaitForTargetAsync, before a code review caught it.
bufferSize is now int? = null, where null defers entirely to ReplaySubject's own
default (unbounded, matching rxjs's own ReplaySubject(bufferSize = Infinity)) instead
of inventing a second, smaller opinionated default. The gap this method targets is
normally microseconds; an unbounded buffer only becomes a real memory concern if a
BufferedEventSource stays attached a long time without ever being subscribed to, which
callers can still avoid by passing an explicit bound for that specific usage.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K92eapPm8e7mX7puT4cF4s
Copy file name to clipboardExpand all lines: src/RxSharp/Extras/FromEventBuffered.cs
+13-17Lines changed: 13 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -69,21 +69,24 @@ public static partial class RxExtensions
69
69
/// <param name="removeHandler">Called on <see cref="BufferedEventSource{TEventArgs}.Dispose"/>, with the same handler, to remove it from the event.</param>
70
70
/// <param name="conversion">Converts an <see cref="Action{TEventArgs}"/> callback into the event's actual delegate shape.</param>
71
71
/// <param name="bufferSize">
72
-
/// The maximum number of most-recent payloads kept for replay. Defaults to 1 - fine if the caller only
73
-
/// cares about the single most recent payload, but a real risk if the caller filters for a specific match
74
-
/// among possibly-several payloads that could arrive in the pre-subscribe gap this method exists to cover:
75
-
/// with the default of 1, a matching payload can be silently evicted from the buffer by a later
76
-
/// non-matching one before anyone subscribes to see it. Pass a larger value whenever more than one payload
77
-
/// could plausibly arrive before subscription and only some of them are what the caller is looking for.
72
+
/// The maximum number of most-recent payloads kept for replay. Defaults to <see langword="null"/>, which
73
+
/// defers entirely to <see cref="ReplaySubject{T}"/>'s own default (unbounded) - this wrapper has no
74
+
/// buffering opinion of its own beyond what the primitive it's built on already does. A caller filtering
75
+
/// for a specific match among payloads that could arrive in the pre-subscribe gap this method exists to
76
+
/// cover needs more than 1: with too small a buffer, a matching payload can be silently evicted by a later
77
+
/// non-matching one before anyone subscribes to see it. Pass an explicit bound only if this source stays
78
+
/// attached for a long time without being subscribed to and unbounded growth is a real concern for that
79
+
/// specific usage - the gap this method targets is normally microseconds, not something an unbounded
80
+
/// buffer meaningfully grows during.
78
81
/// </param>
79
82
/// <returns>A handle exposing the buffered payloads as an observable, and detaching the handler on disposal.</returns>
@@ -93,18 +96,11 @@ public static BufferedEventSource<TEventArgs> FromEventBuffered<TDelegate, TEven
93
96
/// <typeparam name="TEventArgs">The type of the event's payload.</typeparam>
94
97
/// <param name="addHandler">Called immediately, with the handler to add to the event.</param>
95
98
/// <param name="removeHandler">Called on <see cref="BufferedEventSource{TEventArgs}.Dispose"/>, with the same handler, to remove it from the event.</param>
96
-
/// <param name="bufferSize">
97
-
/// The maximum number of most-recent payloads kept for replay. Defaults to 1 - fine if the caller only
98
-
/// cares about the single most recent payload, but a real risk if the caller filters for a specific match
99
-
/// among possibly-several payloads that could arrive in the pre-subscribe gap this method exists to cover:
100
-
/// with the default of 1, a matching payload can be silently evicted from the buffer by a later
101
-
/// non-matching one before anyone subscribes to see it. Pass a larger value whenever more than one payload
102
-
/// could plausibly arrive before subscription and only some of them are what the caller is looking for.
103
-
/// </param>
99
+
/// <param name="bufferSize">See <see cref="FromEventBuffered{TDelegate, TEventArgs}"/>'s parameter of the same name.</param>
104
100
/// <returns>A handle exposing the buffered payloads as an observable, and detaching the handler on disposal.</returns>
0 commit comments