share.js 1.2KB

123456789101112131415161718192021222324
  1. /** PURE_IMPORTS_START .._operators_share PURE_IMPORTS_END */
  2. import { share as higherOrder } from '../operators/share';
  3. /**
  4. * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
  5. * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
  6. * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
  7. *
  8. * This behaves similarly to .publish().refCount(), with a behavior difference when the source observable emits complete.
  9. * .publish().refCount() will not resubscribe to the original source, however .share() will resubscribe to the original source.
  10. * Observable.of("test").publish().refCount() will not re-emit "test" on new subscriptions, Observable.of("test").share() will
  11. * re-emit "test" to new subscriptions.
  12. *
  13. * <img src="./img/share.png" width="100%">
  14. *
  15. * @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
  16. * @method share
  17. * @owner Observable
  18. */
  19. export function share() {
  20. return higherOrder()(this);
  21. }
  22. ;
  23. //# sourceMappingURL=share.js.map