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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * ```ts
  18. * import { fromEvent, of } from 'rxjs';
  19. * import { mapTo, mergeScan } from 'rxjs/operators';
  20. *
  21. * const click$ = fromEvent(document, 'click');
  22. * const one$ = click$.pipe(mapTo(1));
  23. * const seed = 0;
  24. * const count$ = one$.pipe(
  25. * mergeScan((acc, one) => of(acc + one), seed),
  26. * );
  27. * count$.subscribe(x => console.log(x));
  28. *
  29. * // Results:
  30. * // 1
  31. * // 2
  32. * // 3
  33. * // 4
  34. * // ...and so on for each click
  35. * ```
  36. *
  37. * @param {function(acc: R, value: T): Observable<R>} accumulator
  38. * The accumulator function called on each source value.
  39. * @param seed The initial accumulation value.
  40. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of
  41. * input Observables being subscribed to concurrently.
  42. * @return {Observable<R>} An observable of the accumulated values.
  43. * @method mergeScan
  44. * @owner Observable
  45. */
  46. export declare function mergeScan<T, R>(accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, seed: R, concurrent?: number): OperatorFunction<T, R>;
  47. export declare class MergeScanOperator<T, R> implements Operator<T, R> {
  48. private accumulator;
  49. private seed;
  50. private concurrent;
  51. constructor(accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, seed: R, concurrent: number);
  52. call(subscriber: Subscriber<R>, source: any): any;
  53. }
  54. /**
  55. * We need this JSDoc comment for affecting ESDoc.
  56. * @ignore
  57. * @extends {Ignored}
  58. */
  59. export declare class MergeScanSubscriber<T, R> extends OuterSubscriber<T, R> {
  60. private accumulator;
  61. private acc;
  62. private concurrent;
  63. private hasValue;
  64. private hasCompleted;
  65. private buffer;
  66. private active;
  67. protected index: number;
  68. constructor(destination: Subscriber<R>, accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, acc: R, concurrent: number);
  69. protected _next(value: any): void;
  70. private _innerSub;
  71. protected _complete(): void;
  72. notifyNext(outerValue: T, innerValue: R, outerIndex: number, innerIndex: number, innerSub: InnerSubscriber<T, R>): void;
  73. notifyComplete(innerSub: Subscription): void;
  74. }