publish.js 1.0 KB

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