publish.js 1.1 KB

123456789101112131415161718192021222324
  1. "use strict";
  2. var Subject_1 = require('../Subject');
  3. var multicast_1 = require('./multicast');
  4. /* tslint:enable:max-line-length */
  5. /**
  6. * Returns a ConnectableObservable, which is a variety of Observable that waits until its connect method is called
  7. * before it begins emitting items to those Observers that have subscribed to it.
  8. *
  9. * <img src="./img/publish.png" width="100%">
  10. *
  11. * @param {Function} [selector] - Optional selector function which can use the multicasted source sequence as many times
  12. * as needed, without causing multiple subscriptions to the source sequence.
  13. * Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
  14. * @return A ConnectableObservable that upon connection causes the source Observable to emit items to its Observers.
  15. * @method publish
  16. * @owner Observable
  17. */
  18. function publish(selector) {
  19. return selector ?
  20. multicast_1.multicast(function () { return new Subject_1.Subject(); }, selector) :
  21. multicast_1.multicast(new Subject_1.Subject());
  22. }
  23. exports.publish = publish;
  24. //# sourceMappingURL=publish.js.map