Exemplo n.º 1
0
 public static IObservable <T> AggregateAssoc <T>(
     this IObservableList <T> self,
     T seed,
     Func <T, T, T> associativeAccumulator)
 {
     return(self
            .Scan(
                SumTree <T> .Empty(seed, associativeAccumulator),
                (tree, changes) => changes.Apply(tree))
            .Select(tree => tree.Sum()));
 }
Exemplo n.º 2
0
 public static IObservable <int> Count <T>(this IObservableList <T> self)
 {
     return(self.Scan(0,
                      (count, change) =>
     {
         change(
             insert: (i, item) => ++ count,
             replace: (i, item) => { },
             remove: i => -- count,
             clear: () => count = 0);
         return count;
     }).DistinctUntilChanged());
 }
Exemplo n.º 3
0
 public static IObservable <ImmutableList <T> > ToObservableImmutableList <T>(this IObservableList <T> self)
 {
     return(self.Scan(
                ImmutableList <T> .Empty,
                (list, changes) => changes.Apply(list)));
 }