toArray.js 989 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Collects all source emissions and emits them as an array when the source completes.
  6. *
  7. * <span class="informal">Get all values inside an array when the source completes</span>
  8. *
  9. * <img src="./img/toArray.png" width="100%">
  10. *
  11. * `toArray` will wait until the source Observable completes
  12. * before emitting the array containing all emissions.
  13. * When the source Observable errors no array will be emitted.
  14. *
  15. * @example <caption>Create array from input</caption>
  16. * const input = Rx.Observable.interval(100).take(4);
  17. *
  18. * input.toArray()
  19. * .subscribe(arr => console.log(arr)); // [0,1,2,3]
  20. *
  21. * @see {@link buffer}
  22. *
  23. * @return {Observable<any[]>|WebSocketSubject<T>|Observable<T>}
  24. * @method toArray
  25. * @owner Observable
  26. */
  27. function toArray() {
  28. return operators_1.toArray()(this);
  29. }
  30. exports.toArray = toArray;
  31. //# sourceMappingURL=toArray.js.map