12345678910111213141516171819202122232425
  1. "use strict";
  2. var multicast_1 = require('./multicast');
  3. var refCount_1 = require('./refCount');
  4. var Subject_1 = require('../Subject');
  5. function shareSubjectFactory() {
  6. return new Subject_1.Subject();
  7. }
  8. /**
  9. * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
  10. * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
  11. * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
  12. * This is an alias for .multicast(() => new Subject()).refCount().
  13. *
  14. * <img src="./img/share.png" width="100%">
  15. *
  16. * @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
  17. * @method share
  18. * @owner Observable
  19. */
  20. function share() {
  21. return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
  22. }
  23. exports.share = share;
  24. ;
  25. //# sourceMappingURL=share.js.map