我有下面的代码。
this.ObservableForProperty(x => x.SelectedDay)
.Throttle(TimeSpan.FromMilliseconds(3600))
.Where(x => SelectedDay != null)
.ObserveOn(CoreWindow.GetForCurrentThread().Dispatcher)
.Subscribe(x => SomeRandomMethod());
Throttle 运行良好,在 x.SelectedDay 停止更改之前它不会调用 SomeRandomMethod。但是,每次它发生变化时都会调用它。
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