minor adjustment to readme
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / src / internal / operators / share.ts
1 import { Observable } from '../Observable';
2 import { multicast } from './multicast';
3 import { refCount } from './refCount';
4 import { Subject } from '../Subject';
5
6 import { MonoTypeOperatorFunction } from '../types';
7
8 function shareSubjectFactory() {
9   return new Subject();
10 }
11
12 /**
13  * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
14  * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
15  * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
16  * This is an alias for `multicast(() => new Subject()), refCount()`.
17  *
18  * ![](share.png)
19  *
20  * @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
21  * @method share
22  * @owner Observable
23  */
24 export function share<T>(): MonoTypeOperatorFunction<T> {
25   return (source: Observable<T>) => refCount()(multicast(shareSubjectFactory)(source)) as Observable<T>;
26 }