public PointsPresenter(IReadOnlyReactiveProperty <int> pointsAmount) { // Update Points Amount Label Gradually PointsAmountChanged = pointsAmount .Skip(1) .Scan(new { Previous = 0, Current = pointsAmount.Value }, (accumulator, newVal) => new { Previous = accumulator.Current, Current = newVal }) .Select(pair => { var direction = pair.Current > pair.Previous ? 1 : -1; return(Observable.Interval(TimeSpan.FromMilliseconds(30)) .Scan(pair.Previous, (accumulator, _) => accumulator + direction) .TakeWhile(val => val != pair.Current + direction)); }) .Switch() .StartWith(pointsAmount.Value); }
public static IObservable <T> SkipLatestValueOnSubscribe <T>(this IReadOnlyReactiveProperty <T> source) { return(source.HasValue ? source.Skip(1) : source); }
public static UniRx.IObservable <T> SkipLatestValueOnSubscribe <T>(this IReadOnlyReactiveProperty <T> source) { return((!source.HasValue) ? source : source.Skip(1)); }