source: trip-planner-front/node_modules/rxjs/internal/operators/findIndex.d.ts@ 188ee53

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

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { Observable } from '../Observable';
2import { OperatorFunction } from '../types';
3/**
4 * Emits only the index of the first value emitted by the source Observable that
5 * meets some condition.
6 *
7 * <span class="informal">It's like {@link find}, but emits the index of the
8 * found value, not the value itself.</span>
9 *
10 * ![](findIndex.png)
11 *
12 * `findIndex` searches for the first item in the source Observable that matches
13 * the specified condition embodied by the `predicate`, and returns the
14 * (zero-based) index of the first occurrence in the source. Unlike
15 * {@link first}, the `predicate` is required in `findIndex`, and does not emit
16 * an error if a valid value is not found.
17 *
18 * ## Example
19 * Emit the index of first click that happens on a DIV element
20 * ```ts
21 * import { fromEvent } from 'rxjs';
22 * import { findIndex } from 'rxjs/operators';
23 *
24 * const clicks = fromEvent(document, 'click');
25 * const result = clicks.pipe(findIndex(ev => ev.target.tagName === 'DIV'));
26 * result.subscribe(x => console.log(x));
27 * ```
28 *
29 * @see {@link filter}
30 * @see {@link find}
31 * @see {@link first}
32 * @see {@link take}
33 *
34 * @param {function(value: T, index: number, source: Observable<T>): boolean} predicate
35 * A function called with each item to test for condition matching.
36 * @param {any} [thisArg] An optional argument to determine the value of `this`
37 * in the `predicate` function.
38 * @return {Observable} An Observable of the index of the first item that
39 * matches the condition.
40 * @method find
41 * @owner Observable
42 */
43export declare function findIndex<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): OperatorFunction<T, number>;
Note: See TracBrowser for help on using the repository browser.