Front end of the Slack clone application.

find.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** PURE_IMPORTS_START .._operators_find PURE_IMPORTS_END */
  2. import { find as higherOrder } from '../operators/find';
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Emits only the first value emitted by the source Observable that meets some
  6. * condition.
  7. *
  8. * <span class="informal">Finds the first value that passes some test and emits
  9. * that.</span>
  10. *
  11. * <img src="./img/find.png" width="100%">
  12. *
  13. * `find` searches for the first item in the source Observable that matches the
  14. * specified condition embodied by the `predicate`, and returns the first
  15. * occurrence in the source. Unlike {@link first}, the `predicate` is required
  16. * in `find`, and does not emit an error if a valid value is not found.
  17. *
  18. * @example <caption>Find and emit the first click that happens on a DIV element</caption>
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var result = clicks.find(ev => ev.target.tagName === 'DIV');
  21. * result.subscribe(x => console.log(x));
  22. *
  23. * @see {@link filter}
  24. * @see {@link first}
  25. * @see {@link findIndex}
  26. * @see {@link take}
  27. *
  28. * @param {function(value: T, index: number, source: Observable<T>): boolean} predicate
  29. * A function called with each item to test for condition matching.
  30. * @param {any} [thisArg] An optional argument to determine the value of `this`
  31. * in the `predicate` function.
  32. * @return {Observable<T>} An Observable of the first item that matches the
  33. * condition.
  34. * @method find
  35. * @owner Observable
  36. */
  37. export function find(predicate, thisArg) {
  38. return higherOrder(predicate, thisArg)(this);
  39. }
  40. //# sourceMappingURL=find.js.map