Front end of the Slack clone application.

elementAt.d.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Observable } from '../Observable';
  2. /**
  3. * Emits the single value at the specified `index` in a sequence of emissions
  4. * from the source Observable.
  5. *
  6. * <span class="informal">Emits only the i-th value, then completes.</span>
  7. *
  8. * <img src="./img/elementAt.png" width="100%">
  9. *
  10. * `elementAt` returns an Observable that emits the item at the specified
  11. * `index` in the source Observable, or a default value if that `index` is out
  12. * of range and the `default` argument is provided. If the `default` argument is
  13. * not given and the `index` is out of range, the output Observable will emit an
  14. * `ArgumentOutOfRangeError` error.
  15. *
  16. * @example <caption>Emit only the third click event</caption>
  17. * var clicks = Rx.Observable.fromEvent(document, 'click');
  18. * var result = clicks.elementAt(2);
  19. * result.subscribe(x => console.log(x));
  20. *
  21. * // Results in:
  22. * // click 1 = nothing
  23. * // click 2 = nothing
  24. * // click 3 = MouseEvent object logged to console
  25. *
  26. * @see {@link first}
  27. * @see {@link last}
  28. * @see {@link skip}
  29. * @see {@link single}
  30. * @see {@link take}
  31. *
  32. * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an
  33. * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the
  34. * Observable has completed before emitting the i-th `next` notification.
  35. *
  36. * @param {number} index Is the number `i` for the i-th source emission that has
  37. * happened since the subscription, starting from the number `0`.
  38. * @param {T} [defaultValue] The default value returned for missing indices.
  39. * @return {Observable} An Observable that emits a single item, if it is found.
  40. * Otherwise, will emit the default value if given. If not, then emits an error.
  41. * @method elementAt
  42. * @owner Observable
  43. */
  44. export declare function elementAt<T>(this: Observable<T>, index: number, defaultValue?: T): Observable<T>;