Created
June 1, 2015 01:21
-
-
Save ciniml/9c85ce6300c1672d90d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static IObservable<T> DeadTime<T>(this IObservable<T> source, TimeSpan deadTime) | |
{ | |
return Observable.Create<T>(o => | |
{ | |
var subscriptions = new CompositeDisposable(); | |
var lastTime = DateTimeOffset.MinValue; | |
return source | |
.Timestamp() | |
.Where(timestamped => timestamped.Timestamp - lastTime > deadTime) | |
.Do(timestamped => | |
{ | |
lastTime = timestamped.Timestamp; | |
}) | |
.Select(timestamped => timestamped.Value) | |
.Subscribe(o); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment