concat.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var concat_1 = require('../observable/concat');
  3. var concat_2 = require('../observable/concat');
  4. exports.concatStatic = concat_2.concat;
  5. /* tslint:enable:max-line-length */
  6. /**
  7. * Creates an output Observable which sequentially emits all values from every
  8. * given input Observable after the current Observable.
  9. *
  10. * <span class="informal">Concatenates multiple Observables together by
  11. * sequentially emitting their values, one Observable after the other.</span>
  12. *
  13. * <img src="./img/concat.png" width="100%">
  14. *
  15. * Joins this Observable with multiple other Observables by subscribing to them
  16. * one at a time, starting with the source, and merging their results into the
  17. * output Observable. Will wait for each Observable to complete before moving
  18. * on to the next.
  19. *
  20. * @example <caption>Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10</caption>
  21. * var timer = Rx.Observable.interval(1000).take(4);
  22. * var sequence = Rx.Observable.range(1, 10);
  23. * var result = timer.concat(sequence);
  24. * result.subscribe(x => console.log(x));
  25. *
  26. * // results in:
  27. * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10
  28. *
  29. * @example <caption>Concatenate 3 Observables</caption>
  30. * var timer1 = Rx.Observable.interval(1000).take(10);
  31. * var timer2 = Rx.Observable.interval(2000).take(6);
  32. * var timer3 = Rx.Observable.interval(500).take(10);
  33. * var result = timer1.concat(timer2, timer3);
  34. * result.subscribe(x => console.log(x));
  35. *
  36. * // results in the following:
  37. * // (Prints to console sequentially)
  38. * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
  39. * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
  40. * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9
  41. *
  42. * @see {@link concatAll}
  43. * @see {@link concatMap}
  44. * @see {@link concatMapTo}
  45. *
  46. * @param {ObservableInput} other An input Observable to concatenate after the source
  47. * Observable. More than one input Observables may be given as argument.
  48. * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each
  49. * Observable subscription on.
  50. * @return {Observable} All values of each passed Observable merged into a
  51. * single Observable, in order, in serial fashion.
  52. * @method concat
  53. * @owner Observable
  54. */
  55. function concat() {
  56. var observables = [];
  57. for (var _i = 0; _i < arguments.length; _i++) {
  58. observables[_i - 0] = arguments[_i];
  59. }
  60. return function (source) { return source.lift.call(concat_1.concat.apply(void 0, [source].concat(observables))); };
  61. }
  62. exports.concat = concat;
  63. //# sourceMappingURL=concat.js.map