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())); }
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()); }
public static IObservable <ImmutableList <T> > ToObservableImmutableList <T>(this IObservableList <T> self) { return(self.Scan( ImmutableList <T> .Empty, (list, changes) => changes.Apply(list))); }