Skip to content

Commit f54dbec

Browse files
danielcweberOren Novotny
authored andcommitted
The subscription order in SkipUntil is reversed so in case source and other emit elements right away, the first element of source is not missed out. (#530)
1 parent 4d63485 commit f54dbec

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,8 @@ public static IObservable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<I
13651365

13661366
/// <summary>
13671367
/// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
1368+
/// Starting from Rx.NET 4.0, this will subscribe to <paramref name="other"/> before subscribing to <paramref name="source" />
1369+
/// so in case <paramref name="other" /> emits an element right away, elements from <paramref name="source" /> are not missed.
13681370
/// </summary>
13691371
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
13701372
/// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>

Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public IDisposable Run(SkipUntil<TSource, TOther> parent)
3434
var sourceObserver = new SourceObserver(this);
3535
var otherObserver = new OtherObserver(this, sourceObserver);
3636

37-
var sourceSubscription = parent._source.SubscribeSafe(sourceObserver);
3837
var otherSubscription = parent._other.SubscribeSafe(otherObserver);
39-
38+
var sourceSubscription = parent._source.SubscribeSafe(sourceObserver);
39+
4040
sourceObserver.Disposable = sourceSubscription;
4141
otherObserver.Disposable = otherSubscription;
4242

Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableMultipleTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9662,6 +9662,24 @@ public void SkipUntil_HasCompletedCausesDisposal()
96629662
Assert.True(disposed, "disposed");
96639663
}
96649664

9665+
[Fact]
9666+
public void SkipUntil_Immediate()
9667+
{
9668+
var scheduler = new TestScheduler();
9669+
9670+
var xs = Observable.Return(1);
9671+
var ys = Observable.Return("bar");
9672+
9673+
var res = scheduler.Start(() =>
9674+
xs.SkipUntil(ys)
9675+
);
9676+
9677+
res.Messages.AssertEqual(
9678+
OnNext(200, 1),
9679+
OnCompleted<int>(200)
9680+
);
9681+
}
9682+
96659683
#endregion
96669684

96679685
#region + Switch +

0 commit comments

Comments
 (0)