Skip to content

Commit

Permalink
docs(ShareConfig): document default values for each ShareConfig property
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Dec 15, 2022
1 parent 5df07eb commit 2def283
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/internal/operators/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { Subscription } from '../Subscription';
import { MonoTypeOperatorFunction, SubjectLike } from '../types';
import { operate } from '../util/lift';

/**
* The {@link share} operator configuration object interface.
*/
export interface ShareConfig<T> {
/**
* The factory used to create the subject that will connect the source observable to
* multicast consumers.
*
* If not provided, defaults to: `() => new Subject<T>()`
*/
connector?: () => SubjectLike<T>;
/**
Expand All @@ -21,6 +26,8 @@ export interface ShareConfig<T> {
* {@link ReplaySubject} will also push its buffered values before pushing the error.
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
*
* If not provided, defaults to: `true`
*/
resetOnError?: boolean | ((error: any) => Observable<any>);
/**
Expand All @@ -31,6 +38,8 @@ export interface ShareConfig<T> {
* or resubscriptions will resubscribe to that same subject.
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
*
* If not provided, defaults to: `true`
*/
resetOnComplete?: boolean | (() => Observable<any>);
/**
Expand All @@ -42,6 +51,8 @@ export interface ShareConfig<T> {
* will remain connected to the source, and new subscriptions to the result will be connected through that same subject.
* It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
*
* If not provided, defaults to: `true`
*/
resetOnRefCountZero?: boolean | (() => Observable<any>);
}
Expand All @@ -53,8 +64,8 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
/**
* Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
* Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
* This is an alias for `multicast(() => new Subject()), refCount()`.
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream
* {@link guide/glossary-and-semantics#hot hot}.
*
* The subscription to the underlying source Observable can be reset (unsubscribe and resubscribe for new subscribers),
* if the subscriber count to the shared observable drops to 0, or if the source Observable errors or completes. It is
Expand Down Expand Up @@ -136,8 +147,11 @@ export function share<T>(options: ShareConfig<T>): MonoTypeOperatorFunction<T>;
* // subscription 3: 2
* ```
*
* @see {@link ShareConfig}
* @see {@link shareReplay}
*
* @param options A configuration object used to configure things like {@link ShareConfig#connector connector}
* and various reset options.
* @return A function that returns an Observable that mirrors the source.
*/
export function share<T>(options: ShareConfig<T> = {}): MonoTypeOperatorFunction<T> {
Expand Down

0 comments on commit 2def283

Please sign in to comment.