Skip to content

Commit

Permalink
The subscription order in SkipUntil is reversed so in case source and…
Browse files Browse the repository at this point in the history
… other emit elements right away, the first element of source is not missed out. (#530)
  • Loading branch information
danielcweber authored and Oren Novotny committed May 25, 2018
1 parent 4d63485 commit f54dbec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,8 @@ public static IObservable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<I

/// <summary>
/// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
/// Starting from Rx.NET 4.0, this will subscribe to <paramref name="other"/> before subscribing to <paramref name="source" />
/// so in case <paramref name="other" /> emits an element right away, elements from <paramref name="source" /> are not missed.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public IDisposable Run(SkipUntil<TSource, TOther> parent)
var sourceObserver = new SourceObserver(this);
var otherObserver = new OtherObserver(this, sourceObserver);

var sourceSubscription = parent._source.SubscribeSafe(sourceObserver);
var otherSubscription = parent._other.SubscribeSafe(otherObserver);

var sourceSubscription = parent._source.SubscribeSafe(sourceObserver);

sourceObserver.Disposable = sourceSubscription;
otherObserver.Disposable = otherSubscription;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9662,6 +9662,24 @@ public void SkipUntil_HasCompletedCausesDisposal()
Assert.True(disposed, "disposed");
}

[Fact]
public void SkipUntil_Immediate()
{
var scheduler = new TestScheduler();

var xs = Observable.Return(1);
var ys = Observable.Return("bar");

var res = scheduler.Start(() =>
xs.SkipUntil(ys)
);

res.Messages.AssertEqual(
OnNext(200, 1),
OnCompleted<int>(200)
);
}

#endregion

#region + Switch +
Expand Down

0 comments on commit f54dbec

Please sign in to comment.