1
我知道SL5有一个新的属性来计算MouseClicks,但有了帮助,当SL4出来时我得到了这个工作。现在我转移到一台新机器上,下载了RX,并且我知道RX经历了一些破坏此代码的更改。我试过了,但我似乎无法从FastSubject中转换过渡。Rx突然变化
我真的很想在这里完全理解Subject的用法,以及如何更新呼叫以使用当前版本的Rx。
public static IObservable<TSource> MonitorForDoubleClicks<TSource>(this IObservable<TSource> source, TimeSpan doubleClickSpeed, IScheduler scheduler)
{
return source.Multicast<TSource, TSource, TSource>(
() => new FastSubject<TSource>(),
values =>
{
return values
.TimeInterval(scheduler) //injects a timestamp event arguments
.Skip(1) // in order to determine an interval we need two of these, so this keeps the event in the collection, but does not process the first one in
.Where(interval => interval.Interval <= doubleClickSpeed) //second event has arrived, so we can test the interval
.RemoveTimeInterval() //take the time argument out of the event args
.Take(1) //we take one of the events (the latest) and throw it
.Repeat(); //keep the observer alive forever
});