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
});