a zip code crypto-currency system good for red ONLY

partition.d.ts 2.3KB

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