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.

partition.d.ts 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Observable } from '../Observable';
  2. import { UnaryFunction } from '../types';
  3. /**
  4. * Splits the source Observable into two, one with values that satisfy a
  5. * predicate, and another with values that don't satisfy the predicate.
  6. *
  7. * <span class="informal">It's like {@link filter}, but returns two Observables:
  8. * one like the output of {@link filter}, and the other with values that did not
  9. * pass the condition.</span>
  10. *
  11. * ![](partition.png)
  12. *
  13. * `partition` outputs an array with two Observables that partition the values
  14. * from the source Observable through the given `predicate` function. The first
  15. * Observable in that array emits source values for which the predicate argument
  16. * returns true. The second Observable emits source values for which the
  17. * predicate returns false. The first behaves like {@link filter} and the second
  18. * behaves like {@link filter} with the predicate negated.
  19. *
  20. * ## Example
  21. * Partition click events into those on DIV elements and those elsewhere
  22. * ```ts
  23. * import { fromEvent } from 'rxjs';
  24. * import { partition } from 'rxjs/operators';
  25. *
  26. * const clicks = fromEvent(document, 'click');
  27. * const parts = clicks.pipe(partition(ev => ev.target.tagName === 'DIV'));
  28. * const clicksOnDivs = parts[0];
  29. * const clicksElsewhere = parts[1];
  30. * clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
  31. * clicksElsewhere.subscribe(x => console.log('Other clicked: ', x));
  32. * ```
  33. *
  34. * @see {@link filter}
  35. *
  36. * @param {function(value: T, index: number): boolean} predicate A function that
  37. * evaluates each value emitted by the source Observable. If it returns `true`,
  38. * the value is emitted on the first Observable in the returned array, if
  39. * `false` the value is emitted on the second Observable in the array. The
  40. * `index` parameter is the number `i` for the i-th source emission that has
  41. * happened since the subscription, starting from the number `0`.
  42. * @param {any} [thisArg] An optional argument to determine the value of `this`
  43. * in the `predicate` function.
  44. * @return {[Observable<T>, Observable<T>]} An array with two Observables: one
  45. * with values that passed the predicate, and another with values that did not
  46. * pass the predicate.
  47. * @method partition
  48. * @owner Observable
  49. */
  50. /**
  51. * @deprecated use `partition` static creation function instead
  52. */
  53. export declare function partition<T>(predicate: (value: T, index: number) => boolean, thisArg?: any): UnaryFunction<Observable<T>, [Observable<T>, Observable<T>]>;