Пример #1
0
        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);
        }
Пример #2
0
 public static IObservable <T> SkipLatestValueOnSubscribe <T>(this IReadOnlyReactiveProperty <T> source)
 {
     return(source.HasValue ? source.Skip(1) : source);
 }
Пример #3
0
 public static UniRx.IObservable <T> SkipLatestValueOnSubscribe <T>(this IReadOnlyReactiveProperty <T> source)
 {
     return((!source.HasValue) ? source : source.Skip(1));
 }