source: trip-planner-front/node_modules/rxjs/internal/operators/partition.d.ts@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1import { Observable } from '../Observable';
2import { 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 * @deprecated use `partition` static creation function instead
50 */
51export declare function partition<T>(predicate: (value: T, index: number) => boolean, thisArg?: any): UnaryFunction<Observable<T>, [Observable<T>, Observable<T>]>;
Note: See TracBrowser for help on using the repository browser.