Skip to content

Instantly share code, notes, and snippets.

@vcaraulean vcaraulean/rx.cs
Created Sep 18, 2015

Embed
What would you like to do?
TakeUntilIdleFor
public static class Ex {
public static IObservable<T> TakeUntilIdleFor<T>(this IObservable<T> source, TimeSpan idleTime)
{
return Observable.Create<T>(o =>
{
var published = source.Publish();
var idle = published.Select(_ => Observable.Timer(idleTime)).Switch();
return new CompositeDisposable(published.Connect(), published.TakeUntil(idle).Subscribe(o));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.