pluck.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Maps each source value (an object) to its specified nested property.
  6. *
  7. * <span class="informal">Like {@link map}, but meant only for picking one of
  8. * the nested properties of every emitted object.</span>
  9. *
  10. * <img src="./img/pluck.png" width="100%">
  11. *
  12. * Given a list of strings describing a path to an object property, retrieves
  13. * the value of a specified nested property from all values in the source
  14. * Observable. If a property can't be resolved, it will return `undefined` for
  15. * that value.
  16. *
  17. * @example <caption>Map every click to the tagName of the clicked target element</caption>
  18. * var clicks = Rx.Observable.fromEvent(document, 'click');
  19. * var tagNames = clicks.pluck('target', 'tagName');
  20. * tagNames.subscribe(x => console.log(x));
  21. *
  22. * @see {@link map}
  23. *
  24. * @param {...string} properties The nested properties to pluck from each source
  25. * value (an object).
  26. * @return {Observable} A new Observable of property values from the source values.
  27. * @method pluck
  28. * @owner Observable
  29. */
  30. function pluck() {
  31. var properties = [];
  32. for (var _i = 0; _i < arguments.length; _i++) {
  33. properties[_i] = arguments[_i];
  34. }
  35. return operators_1.pluck.apply(void 0, properties)(this);
  36. }
  37. exports.pluck = pluck;
  38. //# sourceMappingURL=pluck.js.map