share.js 1.2 KB

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
  6. * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
  7. * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
  8. *
  9. * This behaves similarly to .publish().refCount(), with a behavior difference when the source observable emits complete.
  10. * .publish().refCount() will not resubscribe to the original source, however .share() will resubscribe to the original source.
  11. * Observable.of("test").publish().refCount() will not re-emit "test" on new subscriptions, Observable.of("test").share() will
  12. * re-emit "test" to new subscriptions.
  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 operators_1.share()(this);
  22. }
  23. exports.share = share;
  24. //# sourceMappingURL=share.js.map