2
0

Observable.Aggregate.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UniRx.Operators;
  5. namespace UniRx
  6. {
  7. public static partial class Observable
  8. {
  9. public static IObservable<TSource> Scan<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
  10. {
  11. return new ScanObservable<TSource>(source, accumulator);
  12. }
  13. public static IObservable<TAccumulate> Scan<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
  14. {
  15. return new ScanObservable<TSource, TAccumulate>(source, seed, accumulator);
  16. }
  17. public static IObservable<TSource> Aggregate<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
  18. {
  19. return new AggregateObservable<TSource>(source, accumulator);
  20. }
  21. public static IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
  22. {
  23. return new AggregateObservable<TSource, TAccumulate>(source, seed, accumulator);
  24. }
  25. public static IObservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector)
  26. {
  27. return new AggregateObservable<TSource, TAccumulate, TResult>(source, seed, accumulator, resultSelector);
  28. }
  29. }
  30. }