source: trip-planner-front/node_modules/rxjs/internal/operators/single.d.ts@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1import { Observable } from '../Observable';
2import { MonoTypeOperatorFunction } from '../types';
3/**
4 * Returns an Observable that emits the single item emitted by the source Observable that matches a specified
5 * predicate, if that Observable emits one such item. If the source Observable emits more than one such item or no
6 * items, notify of an IllegalArgumentException or NoSuchElementException respectively. If the source Observable
7 * emits items but none match the specified predicate then `undefined` is emitted.
8 *
9 * <span class="informal">Like {@link first}, but emit with error notification if there is more than one value.</span>
10 * ![](single.png)
11 *
12 * ## Example
13 * emits 'error'
14 * ```ts
15 * import { range } from 'rxjs';
16 * import { single } from 'rxjs/operators';
17 *
18 * const numbers = range(1,5).pipe(single());
19 * numbers.subscribe(x => console.log('never get called'), e => console.log('error'));
20 * // result
21 * // 'error'
22 * ```
23 *
24 * emits 'undefined'
25 * ```ts
26 * import { range } from 'rxjs';
27 * import { single } from 'rxjs/operators';
28 *
29 * const numbers = range(1,5).pipe(single(x => x === 10));
30 * numbers.subscribe(x => console.log(x));
31 * // result
32 * // 'undefined'
33 * ```
34 *
35 * @see {@link first}
36 * @see {@link find}
37 * @see {@link findIndex}
38 * @see {@link elementAt}
39 *
40 * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
41 * callback if the Observable completes before any `next` notification was sent.
42 * @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable.
43 * @return {Observable<T>} An Observable that emits the single item emitted by the source Observable that matches
44 * the predicate or `undefined` when no items match.
45 *
46 * @method single
47 * @owner Observable
48 */
49export declare function single<T>(predicate?: (value: T, index: number, source: Observable<T>) => boolean): MonoTypeOperatorFunction<T>;
Note: See TracBrowser for help on using the repository browser.