0
我有以下代码。反应性扩展(UI)增加事件调用
this.ObservableForProperty(x => x.SelectedDay)
.Throttle(TimeSpan.FromMilliseconds(3600))
.Where(x => SelectedDay != null)
.ObserveOn(CoreWindow.GetForCurrentThread().Dispatcher)
.Subscribe(x => SomeRandomMethod());
油门工作的很好,它不会调用SomeRandomMethod,直到x.SelectedDay停止更改。然而,它每次改变时都会调用它。
So i do this:
Change,
Change,
Wait
//SomeRandomMethod called 2 times at end of throttle
Change
Wait
//SomeRandomMethod called 3 times
Change
Change
Change
Wait
//SomeRandomMethod called 6 times.
我怎样才能得到它忽略所有以前的变化事件,只有在节流阀做了它的事情最新的时间。
So i would like this:
Change
Change
Wait
//SomeRandomMethod called once
Change
Wait
//SomeRandomMethod called once
Change
Change
Change
Wait
//SomeRandomMethod called once
哈哈,当然。感觉这样一个愚蠢的屁股。 'RxApp.DeferredScheduler'也很好用。非常感谢。 – 4imble 2013-03-12 09:23:08
@Kohan不用担心,这是一个常见的错误。尝试将RxUI调用看作描述事物是如何相关的 - 这是一个声明,就像XAML绑定一样。 – 2013-03-12 21:32:47