Created
September 18, 2015 15:11
-
-
Save vcaraulean/dfc374b2f1677c072d1f to your computer and use it in GitHub Desktop.
TakeUntilIdleFor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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