Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mergeScan.d.ts 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { Operator } from '../Operator';
  2. import { Subscriber } from '../Subscriber';
  3. import { Subscription } from '../Subscription';
  4. import { OuterSubscriber } from '../OuterSubscriber';
  5. import { InnerSubscriber } from '../InnerSubscriber';
  6. import { ObservableInput, OperatorFunction } from '../types';
  7. /**
  8. * Applies an accumulator function over the source Observable where the
  9. * accumulator function itself returns an Observable, then each intermediate
  10. * Observable returned is merged into the output Observable.
  11. *
  12. * <span class="informal">It's like {@link scan}, but the Observables returned
  13. * by the accumulator are merged into the outer Observable.</span>
  14. *
  15. * ## Example
  16. * Count the number of click events
  17. * ```javascript
  18. * const click$ = fromEvent(document, 'click');
  19. * const one$ = click$.pipe(mapTo(1));
  20. * const seed = 0;
  21. * const count$ = one$.pipe(
  22. * mergeScan((acc, one) => of(acc + one), seed),
  23. * );
  24. * count$.subscribe(x => console.log(x));
  25. *
  26. * // Results:
  27. * 1
  28. * 2
  29. * 3
  30. * 4
  31. * // ...and so on for each click
  32. * ```
  33. *
  34. * @param {function(acc: R, value: T): Observable<R>} accumulator
  35. * The accumulator function called on each source value.
  36. * @param seed The initial accumulation value.
  37. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of
  38. * input Observables being subscribed to concurrently.
  39. * @return {Observable<R>} An observable of the accumulated values.
  40. * @method mergeScan
  41. * @owner Observable
  42. */
  43. export declare function mergeScan<T, R>(accumulator: (acc: R, value: T) => ObservableInput<R>, seed: R, concurrent?: number): OperatorFunction<T, R>;
  44. export declare class MergeScanOperator<T, R> implements Operator<T, R> {
  45. private accumulator;
  46. private seed;
  47. private concurrent;
  48. constructor(accumulator: (acc: R, value: T) => ObservableInput<R>, seed: R, concurrent: number);
  49. call(subscriber: Subscriber<R>, source: any): any;
  50. }
  51. /**
  52. * We need this JSDoc comment for affecting ESDoc.
  53. * @ignore
  54. * @extends {Ignored}
  55. */
  56. export declare class MergeScanSubscriber<T, R> extends OuterSubscriber<T, R> {
  57. private accumulator;
  58. private acc;
  59. private concurrent;
  60. private hasValue;
  61. private hasCompleted;
  62. private buffer;
  63. private active;
  64. protected index: number;
  65. constructor(destination: Subscriber<R>, accumulator: (acc: R, value: T) => ObservableInput<R>, acc: R, concurrent: number);
  66. protected _next(value: any): void;
  67. private _innerSub;
  68. protected _complete(): void;
  69. notifyNext(outerValue: T, innerValue: R, outerIndex: number, innerIndex: number, innerSub: InnerSubscriber<T, R>): void;
  70. notifyComplete(innerSub: Subscription): void;
  71. }