Skip to content

Commit a609104

Browse files
committed
Added documentation for clarity on the shadowing behavior of DynamicData's .Switch() operators. (#1154)
(cherry picked from commit 7f39e49)
1 parent 0e5f3c0 commit a609104

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎src/DynamicData/Cache/ObservableCacheEx.Switch.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static IObservable<IChangeSet<TObject, TKey>> Switch<TObject, TKey>(this
4848
/// <remarks>
4949
/// <para>On switch: <b>Remove</b> is emitted for all items from the previous source, then <b>Add</b> for all items from the new source.</para>
5050
/// <para><b>Worth noting:</b> Each switch clears the entire downstream cache before populating from the new source. Subscribers see a full remove-then-add reset on every switch.</para>
51+
/// <para><b>Also worth noting:</b>This operator intentionally shadows the native <see cref="Observable.Switch{TSource}(IObservable{IObservable{TSource}})"/> operator, as downstream listeners will generally become corrupt when the native operator is used. This is due to its lack of the automatic-clearing behavior mentioned above.</para>
5152
/// </remarks>
5253
public static IObservable<IChangeSet<TObject, TKey>> Switch<TObject, TKey>(this IObservable<IObservable<IChangeSet<TObject, TKey>>> sources)
5354
where TObject : notnull

‎src/DynamicData/List/ObservableListEx.Switch.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ public static IObservable<IChangeSet<T>> Switch<T>(this IObservable<IObservableL
5252
/// <returns>A list changeset stream reflecting the most recently received inner changeset stream.</returns>
5353
/// <exception cref="ArgumentNullException"><paramref name="sources"/> is <see langword="null"/>.</exception>
5454
/// <remarks>
55-
/// <para>
56-
/// On each new inner stream, the operator clears the destination, disposes the previous subscription, and subscribes to the new stream.
57-
/// This is the changeset-aware equivalent of Rx's <c>Switch()</c>.
58-
/// </para>
55+
/// <para><b>Worth noting:</b> Each switch clears the entire downstream list before populating from the new source. Subscribers see a full remove-then-add reset on every switch.</para>
56+
/// <para><b>Also worth noting:</b>This operator intentionally shadows the native <see cref="Observable.Switch{TSource}(IObservable{IObservable{TSource}})"/> operator, as downstream listeners will generally become corrupt when the native operator is used. This is due to its lack of the automatic-clearing behavior mentioned above.</para>
5957
/// </remarks>
6058
/// <seealso cref="Switch{T}(IObservable{IObservableList{T}})"/>
6159
public static IObservable<IChangeSet<T>> Switch<T>(this IObservable<IObservable<IChangeSet<T>>> sources)

0 commit comments

Comments
 (0)
⌂ 换网址