Skip to content

Instantly share code, notes, and snippets.

@vcaraulean
Created September 18, 2015 15:11
Show Gist options
  • Save vcaraulean/dfc374b2f1677c072d1f to your computer and use it in GitHub Desktop.
Save vcaraulean/dfc374b2f1677c072d1f to your computer and use it in GitHub Desktop.
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