single.d.ts 1.0 KB

12345678910111213141516171819
  1. import { Observable } from '../Observable';
  2. import { MonoTypeOperatorFunction } from '../interfaces';
  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. * such items, notify of an IllegalArgumentException or NoSuchElementException respectively.
  7. *
  8. * <img src="./img/single.png" width="100%">
  9. *
  10. * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
  11. * callback if the Observable completes before any `next` notification was sent.
  12. * @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable.
  13. * @return {Observable<T>} An Observable that emits the single item emitted by the source Observable that matches
  14. * the predicate.
  15. .
  16. * @method single
  17. * @owner Observable
  18. */
  19. export declare function single<T>(predicate?: (value: T, index: number, source: Observable<T>) => boolean): MonoTypeOperatorFunction<T>;