last.js 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /* tslint:enable:max-line-length */
  5. /**
  6. * Returns an Observable that emits only the last item emitted by the source Observable.
  7. * It optionally takes a predicate function as a parameter, in which case, rather than emitting
  8. * the last item from the source Observable, the resulting Observable will emit the last item
  9. * from the source Observable that satisfies the predicate.
  10. *
  11. * <img src="./img/last.png" width="100%">
  12. *
  13. * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
  14. * callback if the Observable completes before any `next` notification was sent.
  15. * @param {function} [predicate] - The condition any source emitted item has to satisfy.
  16. * @param {any} [defaultValue] - The default value to use if the predicate isn't
  17. * satisfied, or no values were emitted (if no predicate).
  18. * @return {Observable} An Observable that emits only the last item satisfying the given condition
  19. * from the source, or an NoSuchElementException if no such items are emitted.
  20. * @throws - Throws if no items that match the predicate are emitted by the source Observable.
  21. * @method last
  22. * @owner Observable
  23. */
  24. function last() {
  25. var args = [];
  26. for (var _i = 0; _i < arguments.length; _i++) {
  27. args[_i] = arguments[_i];
  28. }
  29. return operators_1.last.apply(void 0, args)(this);
  30. }
  31. exports.last = last;
  32. //# sourceMappingURL=last.js.map