pluck.d.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { OperatorFunction } from '../interfaces';
  2. /**
  3. * Maps each source value (an object) to its specified nested property.
  4. *
  5. * <span class="informal">Like {@link map}, but meant only for picking one of
  6. * the nested properties of every emitted object.</span>
  7. *
  8. * <img src="./img/pluck.png" width="100%">
  9. *
  10. * Given a list of strings describing a path to an object property, retrieves
  11. * the value of a specified nested property from all values in the source
  12. * Observable. If a property can't be resolved, it will return `undefined` for
  13. * that value.
  14. *
  15. * @example <caption>Map every click to the tagName of the clicked target element</caption>
  16. * var clicks = Rx.Observable.fromEvent(document, 'click');
  17. * var tagNames = clicks.pluck('target', 'tagName');
  18. * tagNames.subscribe(x => console.log(x));
  19. *
  20. * @see {@link map}
  21. *
  22. * @param {...string} properties The nested properties to pluck from each source
  23. * value (an object).
  24. * @return {Observable} A new Observable of property values from the source values.
  25. * @method pluck
  26. * @owner Observable
  27. */
  28. export declare function pluck<T, R>(...properties: string[]): OperatorFunction<T, R>;