Skip to content

Commit aed2ced

Browse files
docs(ShareConfig): document default values for each ShareConfig property
1 parent 4afbc16 commit aed2ced

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/internal/operators/share.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import { Subscription } from '../Subscription';
66
import { MonoTypeOperatorFunction, SubjectLike } from '../types';
77
import { operate } from '../util/lift';
88

9+
/**
10+
* The {@link share} operator configuration object interface.
11+
*/
912
export interface ShareConfig<T> {
1013
/**
1114
* The factory used to create the subject that will connect the source observable to
1215
* multicast consumers.
16+
*
17+
* If not provided, defaults to: `() => new Subject<T>()`
1318
*/
1419
connector?: () => SubjectLike<T>;
1520
/**
@@ -21,6 +26,8 @@ export interface ShareConfig<T> {
2126
* {@link ReplaySubject} will also push its buffered values before pushing the error.
2227
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
2328
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
29+
*
30+
* If not provided, defaults to: `true`
2431
*/
2532
resetOnError?: boolean | ((error: any) => Observable<any>);
2633
/**
@@ -31,6 +38,8 @@ export interface ShareConfig<T> {
3138
* or resubscriptions will resubscribe to that same subject.
3239
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
3340
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
41+
*
42+
* If not provided, defaults to: `true`
3443
*/
3544
resetOnComplete?: boolean | (() => Observable<any>);
3645
/**
@@ -42,6 +51,8 @@ export interface ShareConfig<T> {
4251
* will remain connected to the source, and new subscriptions to the result will be connected through that same subject.
4352
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
4453
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
54+
*
55+
* If not provided, defaults to: `true`
4556
*/
4657
resetOnRefCountZero?: boolean | (() => Observable<any>);
4758
}
@@ -53,8 +64,8 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
5364
/**
5465
* Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
5566
* Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
56-
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
57-
* This is an alias for `multicast(() => new Subject()), refCount()`.
67+
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream
68+
* {@link guide/glossary-and-semantics#hot hot}.
5869
*
5970
* The subscription to the underlying source Observable can be reset (unsubscribe and resubscribe for new subscribers),
6071
* if the subscriber count to the shared observable drops to 0, or if the source Observable errors or completes. It is
@@ -136,8 +147,11 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
136147
* // subscription 3: 2
137148
* ```
138149
*
150+
* @see {@link ShareConfig}
139151
* @see {@link shareReplay}
140152
*
153+
* @param options A configuration object used to configure things like {@link ShareConfig#connector connector}
154+
* and various reset options.
141155
* @return A function that returns an Observable that mirrors the source.
142156
*/
143157
export function share<T>(options: ShareConfig<T> = {}): MonoTypeOperatorFunction<T> {

0 commit comments

Comments
 (0)