예제 #1
0
        public static Optional <TResult> ChangesTo <TArgs, TResult>(
            this OptionalPreviousCurrentTuple <TArgs> self,
            Func <TArgs, TResult> select)
        {
            var prev = self.Previous.Select(select);
            var cur  = select(self.Current);

            if (prev.Equals(cur))
            {
                return(Optional.None());
            }
            return(cur);
        }
예제 #2
0
 public static IObservable <OptionalPreviousCurrentTuple <T> > BufferPrevious <T>(this IObservable <T> self)
 {
     return(Observable.Create <OptionalPreviousCurrentTuple <T> >(
                observer =>
     {
         var previous = Optional.None <T>();
         return self
         .Select(current =>
         {
             var ret = new OptionalPreviousCurrentTuple <T>(previous, current);
             previous = current;
             return ret;
         })
         .Subscribe(observer);
     }));
 }