From 53d9be6c8e2c9176c88103b335a6dd0db8630c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Jakovljevi=C4=87?= Date: Mon, 10 May 2021 10:49:52 +0200 Subject: [PATCH 1/5] docs: include additional interfaces to docs --- src/index.ts | 6 ++++++ src/internal/operators/connect.ts | 3 +++ src/internal/operators/throttle.ts | 3 ++- src/internal/operators/timeout.ts | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1e28bda97d..475b2c6980 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,6 +95,12 @@ export { NEVER } from './internal/observable/never'; /* Types */ export * from './internal/types'; +export { ConnectConfig } from './internal/operators/connect'; +export { RetryConfig } from './internal/operators/retry'; +export { ShareConfig } from './internal/operators/share'; +export { ShareReplayConfig } from './internal/operators/shareReplay'; +export { ThrottleConfig } from './internal/operators/throttle'; +export { TimeoutConfig, TimeoutInfo } from './internal/operators/timeout'; /* Config */ export { config, GlobalConfig } from './internal/config'; diff --git a/src/internal/operators/connect.ts b/src/internal/operators/connect.ts index 3c666d6932..fd3c6cd3e7 100644 --- a/src/internal/operators/connect.ts +++ b/src/internal/operators/connect.ts @@ -5,6 +5,9 @@ import { from } from '../observable/from'; import { operate } from '../util/lift'; import { fromSubscribable } from '../observable/fromSubscribable'; +/** + * An object used to configure {@link connect} operator. + */ export interface ConnectConfig { /** * A factory function used to create the Subject through which the source diff --git a/src/internal/operators/throttle.ts b/src/internal/operators/throttle.ts index b5dec74bea..8ca5b11eee 100644 --- a/src/internal/operators/throttle.ts +++ b/src/internal/operators/throttle.ts @@ -61,9 +61,10 @@ export const defaultThrottleConfig: ThrottleConfig = { */ export function throttle( durationSelector: (value: T) => ObservableInput, - { leading, trailing }: ThrottleConfig = defaultThrottleConfig + config: ThrottleConfig = defaultThrottleConfig ): MonoTypeOperatorFunction { return operate((source, subscriber) => { + const { leading, trailing } = config; let hasValue = false; let sendValue: T | null = null; let throttled: Subscription | null = null; diff --git a/src/internal/operators/timeout.ts b/src/internal/operators/timeout.ts index 8e33cde9b2..92572acd44 100644 --- a/src/internal/operators/timeout.ts +++ b/src/internal/operators/timeout.ts @@ -28,7 +28,7 @@ export interface TimeoutConfig = Observabl /** * A factory used to create observable to switch to when timeout occurs. Provides - * some information about the source observable's emissions and what delay or + * a {@link TimeoutInfo} about the source observable's emissions and what delay or * exact time triggered the timeout. */ with?: (info: TimeoutInfo) => O; From 05180258496ec73f3ebea2cf4a8af85930c0389e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Jakovljevi=C4=87?= Date: Mon, 10 May 2021 11:47:27 +0200 Subject: [PATCH 2/5] chore: update api_guardian --- api_guard/dist/types/index.d.ts | 42 +++++++++++++++++++++++ api_guard/dist/types/operators/index.d.ts | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 4c34cc78a3..2c1822c154 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -86,6 +86,10 @@ export declare class ConnectableObservable extends Observable { refCount(): Observable; } +export interface ConnectConfig { + connector: () => SubjectLike; +} + export declare type Cons = ((arg: X, ...rest: Y) => any) extends (...args: infer U) => any ? U : never; export declare function defer>(observableFactory: () => R): Observable>; @@ -366,6 +370,11 @@ export declare class ReplaySubject extends Subject { next(value: T): void; } +export interface RetryConfig { + count: number; + resetOnSuccess?: boolean; +} + export declare function scheduled(input: ObservableInput, scheduler: SchedulerLike): Observable; export declare class Scheduler implements SchedulerLike { @@ -388,6 +397,20 @@ export interface SequenceError extends Error { export declare const SequenceError: SequenceErrorCtor; +export interface ShareConfig { + connector?: () => SubjectLike; + resetOnComplete?: boolean; + resetOnError?: boolean; + resetOnRefCountZero?: boolean; +} + +export interface ShareReplayConfig { + bufferSize?: number; + refCount: boolean; + scheduler?: SchedulerLike; + windowTime?: number; +} + export declare class Subject extends Observable implements SubscriptionLike { closed: boolean; hasError: boolean; @@ -446,6 +469,11 @@ export declare type Tail = ((...args: X) => any) exten export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void; +export interface ThrottleConfig { + leading?: boolean; + trailing?: boolean; +} + export declare function throwError(errorFactory: () => any): Observable; export declare function throwError(error: any): Observable; export declare function throwError(errorOrErrorFactory: any, scheduler: SchedulerLike): Observable; @@ -455,12 +483,26 @@ export interface TimeInterval { value: T; } +export interface TimeoutConfig = ObservableInput, M = unknown> { + each?: number; + first?: number | Date; + meta?: M; + scheduler?: SchedulerLike; + with?: (info: TimeoutInfo) => O; +} + export interface TimeoutError extends Error { info: TimeoutInfo | null; } export declare const TimeoutError: TimeoutErrorCtor; +export interface TimeoutInfo { + readonly lastValue: T | null; + readonly meta: M; + readonly seen: number; +} + export declare function timer(due: number | Date, scheduler?: SchedulerLike): Observable<0>; export declare function timer(startDue: number | Date, intervalDuration: number, scheduler?: SchedulerLike): Observable; export declare function timer(dueTime: number | Date, unused: undefined, scheduler?: SchedulerLike): Observable<0>; diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index b08bc94cee..d984da6508 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -287,7 +287,7 @@ export declare function tap(observer?: Partial>): MonoTypeOperato export declare function tap(next: (value: T) => void): MonoTypeOperatorFunction; export declare function tap(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): MonoTypeOperatorFunction; -export declare function throttle(durationSelector: (value: T) => ObservableInput, { leading, trailing }?: ThrottleConfig): MonoTypeOperatorFunction; +export declare function throttle(durationSelector: (value: T) => ObservableInput, config?: ThrottleConfig): MonoTypeOperatorFunction; export declare function throttleTime(duration: number, scheduler?: SchedulerLike, config?: import("./throttle").ThrottleConfig): MonoTypeOperatorFunction; From fe1e2d6594947cb206856bc9a24c64670744bb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Jakovljevi=C4=87?= Date: Mon, 10 May 2021 21:22:17 +0200 Subject: [PATCH 3/5] chore: move interfaces to operators/index.ts --- api_guard/dist/types/index.d.ts | 42 ----------------------- api_guard/dist/types/operators/index.d.ts | 42 +++++++++++++++++++++++ src/index.ts | 6 ---- src/operators/index.ts | 12 +++---- 4 files changed, 48 insertions(+), 54 deletions(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 2c1822c154..4c34cc78a3 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -86,10 +86,6 @@ export declare class ConnectableObservable extends Observable { refCount(): Observable; } -export interface ConnectConfig { - connector: () => SubjectLike; -} - export declare type Cons = ((arg: X, ...rest: Y) => any) extends (...args: infer U) => any ? U : never; export declare function defer>(observableFactory: () => R): Observable>; @@ -370,11 +366,6 @@ export declare class ReplaySubject extends Subject { next(value: T): void; } -export interface RetryConfig { - count: number; - resetOnSuccess?: boolean; -} - export declare function scheduled(input: ObservableInput, scheduler: SchedulerLike): Observable; export declare class Scheduler implements SchedulerLike { @@ -397,20 +388,6 @@ export interface SequenceError extends Error { export declare const SequenceError: SequenceErrorCtor; -export interface ShareConfig { - connector?: () => SubjectLike; - resetOnComplete?: boolean; - resetOnError?: boolean; - resetOnRefCountZero?: boolean; -} - -export interface ShareReplayConfig { - bufferSize?: number; - refCount: boolean; - scheduler?: SchedulerLike; - windowTime?: number; -} - export declare class Subject extends Observable implements SubscriptionLike { closed: boolean; hasError: boolean; @@ -469,11 +446,6 @@ export declare type Tail = ((...args: X) => any) exten export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void; -export interface ThrottleConfig { - leading?: boolean; - trailing?: boolean; -} - export declare function throwError(errorFactory: () => any): Observable; export declare function throwError(error: any): Observable; export declare function throwError(errorOrErrorFactory: any, scheduler: SchedulerLike): Observable; @@ -483,26 +455,12 @@ export interface TimeInterval { value: T; } -export interface TimeoutConfig = ObservableInput, M = unknown> { - each?: number; - first?: number | Date; - meta?: M; - scheduler?: SchedulerLike; - with?: (info: TimeoutInfo) => O; -} - export interface TimeoutError extends Error { info: TimeoutInfo | null; } export declare const TimeoutError: TimeoutErrorCtor; -export interface TimeoutInfo { - readonly lastValue: T | null; - readonly meta: M; - readonly seen: number; -} - export declare function timer(due: number | Date, scheduler?: SchedulerLike): Observable<0>; export declare function timer(startDue: number | Date, intervalDuration: number, scheduler?: SchedulerLike): Observable; export declare function timer(dueTime: number | Date, unused: undefined, scheduler?: SchedulerLike): Observable<0>; diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index d984da6508..80d7b97365 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -47,6 +47,10 @@ export declare function concatWith(...otherSour export declare function connect>(selector: (shared: Observable) => O, config?: ConnectConfig): OperatorFunction>; +export interface ConnectConfig { + connector: () => SubjectLike; +} + export declare function count(predicate?: (value: T, index: number) => boolean): OperatorFunction; export declare function debounce(durationSelector: (value: T) => ObservableInput): MonoTypeOperatorFunction; @@ -220,6 +224,11 @@ export declare function repeatWhen(notifier: (notifications: Observable export declare function retry(count?: number): MonoTypeOperatorFunction; export declare function retry(config: RetryConfig): MonoTypeOperatorFunction; +export interface RetryConfig { + count: number; + resetOnSuccess?: boolean; +} + export declare function retryWhen(notifier: (errors: Observable) => Observable): MonoTypeOperatorFunction; export declare function sample(notifier: Observable): MonoTypeOperatorFunction; @@ -235,9 +244,23 @@ export declare function sequenceEqual(compareTo: Observable, comparator?: export declare function share(): MonoTypeOperatorFunction; export declare function share(options: ShareConfig): MonoTypeOperatorFunction; +export interface ShareConfig { + connector?: () => SubjectLike; + resetOnComplete?: boolean; + resetOnError?: boolean; + resetOnRefCountZero?: boolean; +} + export declare function shareReplay(config: ShareReplayConfig): MonoTypeOperatorFunction; export declare function shareReplay(bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; +export interface ShareReplayConfig { + bufferSize?: number; + refCount: boolean; + scheduler?: SchedulerLike; + windowTime?: number; +} + export declare function single(predicate: BooleanConstructor): OperatorFunction>; export declare function single(predicate?: (value: T, index: number, source: Observable) => boolean): MonoTypeOperatorFunction; @@ -289,6 +312,11 @@ export declare function tap(next?: ((value: T) => void) | null, error?: ((err export declare function throttle(durationSelector: (value: T) => ObservableInput, config?: ThrottleConfig): MonoTypeOperatorFunction; +export interface ThrottleConfig { + leading?: boolean; + trailing?: boolean; +} + export declare function throttleTime(duration: number, scheduler?: SchedulerLike, config?: import("./throttle").ThrottleConfig): MonoTypeOperatorFunction; export declare function throwIfEmpty(errorFactory?: () => any): MonoTypeOperatorFunction; @@ -302,6 +330,20 @@ export declare function timeout(config: Omit(first: Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction; export declare function timeout(each: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; +export interface TimeoutConfig = ObservableInput, M = unknown> { + each?: number; + first?: number | Date; + meta?: M; + scheduler?: SchedulerLike; + with?: (info: TimeoutInfo) => O; +} + +export interface TimeoutInfo { + readonly lastValue: T | null; + readonly meta: M; + readonly seen: number; +} + export declare function timeoutWith(dueBy: Date, switchTo: ObservableInput, scheduler?: SchedulerLike): OperatorFunction; export declare function timeoutWith(waitFor: number, switchTo: ObservableInput, scheduler?: SchedulerLike): OperatorFunction; diff --git a/src/index.ts b/src/index.ts index 475b2c6980..1e28bda97d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,12 +95,6 @@ export { NEVER } from './internal/observable/never'; /* Types */ export * from './internal/types'; -export { ConnectConfig } from './internal/operators/connect'; -export { RetryConfig } from './internal/operators/retry'; -export { ShareConfig } from './internal/operators/share'; -export { ShareReplayConfig } from './internal/operators/shareReplay'; -export { ThrottleConfig } from './internal/operators/throttle'; -export { TimeoutConfig, TimeoutInfo } from './internal/operators/timeout'; /* Config */ export { config, GlobalConfig } from './internal/config'; diff --git a/src/operators/index.ts b/src/operators/index.ts index b98bcfab03..fd5c9dd6c1 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -16,7 +16,7 @@ export { concatAll } from '../internal/operators/concatAll'; export { concatMap } from '../internal/operators/concatMap'; export { concatMapTo } from '../internal/operators/concatMapTo'; export { concatWith } from '../internal/operators/concatWith'; -export { connect } from '../internal/operators/connect'; +export { connect, ConnectConfig } from '../internal/operators/connect'; export { count } from '../internal/operators/count'; export { debounce } from '../internal/operators/debounce'; export { debounceTime } from '../internal/operators/debounceTime'; @@ -70,15 +70,15 @@ export { raceWith } from '../internal/operators/raceWith'; export { reduce } from '../internal/operators/reduce'; export { repeat } from '../internal/operators/repeat'; export { repeatWhen } from '../internal/operators/repeatWhen'; -export { retry } from '../internal/operators/retry'; +export { retry, RetryConfig } from '../internal/operators/retry'; export { retryWhen } from '../internal/operators/retryWhen'; export { refCount } from '../internal/operators/refCount'; export { sample } from '../internal/operators/sample'; export { sampleTime } from '../internal/operators/sampleTime'; export { scan } from '../internal/operators/scan'; export { sequenceEqual } from '../internal/operators/sequenceEqual'; -export { share } from '../internal/operators/share'; -export { shareReplay } from '../internal/operators/shareReplay'; +export { share, ShareConfig } from '../internal/operators/share'; +export { shareReplay, ShareReplayConfig } from '../internal/operators/shareReplay'; export { single } from '../internal/operators/single'; export { skip } from '../internal/operators/skip'; export { skipLast } from '../internal/operators/skipLast'; @@ -95,11 +95,11 @@ export { takeLast } from '../internal/operators/takeLast'; export { takeUntil } from '../internal/operators/takeUntil'; export { takeWhile } from '../internal/operators/takeWhile'; export { tap } from '../internal/operators/tap'; -export { throttle } from '../internal/operators/throttle'; +export { throttle, ThrottleConfig } from '../internal/operators/throttle'; export { throttleTime } from '../internal/operators/throttleTime'; export { throwIfEmpty } from '../internal/operators/throwIfEmpty'; export { timeInterval } from '../internal/operators/timeInterval'; -export { timeout } from '../internal/operators/timeout'; +export { timeout, TimeoutConfig, TimeoutInfo } from '../internal/operators/timeout'; export { timeoutWith } from '../internal/operators/timeoutWith'; export { timestamp } from '../internal/operators/timestamp'; export { toArray } from '../internal/operators/toArray'; From 729bff915285860bfa1c77757e0a04c2c1fafd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Jakovljevi=C4=87?= Date: Tue, 25 May 2021 10:19:50 +0200 Subject: [PATCH 4/5] docs: include new groupBy interfaces --- src/internal/operators/groupBy.ts | 4 ++-- src/operators/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal/operators/groupBy.ts b/src/internal/operators/groupBy.ts index 30c7c46e4a..808b9dd743 100644 --- a/src/internal/operators/groupBy.ts +++ b/src/internal/operators/groupBy.ts @@ -5,13 +5,13 @@ import { ObservableInput, Observer, OperatorFunction, SubjectLike } from '../typ import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; -interface BasicGroupByOptions { +export interface BasicGroupByOptions { element?: undefined; duration?: (grouped: GroupedObservable) => ObservableInput; connector?: () => SubjectLike; } -interface GroupByOptionsWithElement { +export interface GroupByOptionsWithElement { element: (value: T) => E; duration?: (grouped: GroupedObservable) => ObservableInput; connector?: () => SubjectLike; diff --git a/src/operators/index.ts b/src/operators/index.ts index fd5c9dd6c1..9272c89780 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -39,7 +39,7 @@ export { finalize } from '../internal/operators/finalize'; export { find } from '../internal/operators/find'; export { findIndex } from '../internal/operators/findIndex'; export { first } from '../internal/operators/first'; -export { groupBy } from '../internal/operators/groupBy'; +export { groupBy, BasicGroupByOptions, GroupByOptionsWithElement } from '../internal/operators/groupBy'; export { ignoreElements } from '../internal/operators/ignoreElements'; export { isEmpty } from '../internal/operators/isEmpty'; export { last } from '../internal/operators/last'; From a1b98915b46aa4d40d3b93108c87fc015e7c3728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Jakovljevi=C4=87?= Date: Tue, 25 May 2021 10:23:19 +0200 Subject: [PATCH 5/5] chore: update api_guardian --- api_guard/dist/types/operators/index.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index 80d7b97365..cb67ee951d 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -2,6 +2,12 @@ export declare function audit(durationSelector: (value: T) => ObservableInput export declare function auditTime(duration: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; +export interface BasicGroupByOptions { + connector?: () => SubjectLike; + duration?: (grouped: GroupedObservable) => ObservableInput; + element?: undefined; +} + export declare function buffer(closingNotifier: Observable): OperatorFunction; export declare function bufferCount(bufferSize: number, startBufferEvery?: number | null): OperatorFunction; @@ -132,6 +138,12 @@ export declare function groupBy(key: (value: T) => K, element: void, durat export declare function groupBy(key: (value: T) => K, element?: (value: T) => R, duration?: (grouped: GroupedObservable) => Observable): OperatorFunction>; export declare function groupBy(key: (value: T) => K, element?: (value: T) => R, duration?: (grouped: GroupedObservable) => Observable, connector?: () => Subject): OperatorFunction>; +export interface GroupByOptionsWithElement { + connector?: () => SubjectLike; + duration?: (grouped: GroupedObservable) => ObservableInput; + element: (value: T) => E; +} + export declare function ignoreElements(): OperatorFunction; export declare function isEmpty(): OperatorFunction; @@ -246,9 +258,9 @@ export declare function share(options: ShareConfig): MonoTypeOperatorFunct export interface ShareConfig { connector?: () => SubjectLike; - resetOnComplete?: boolean; - resetOnError?: boolean; - resetOnRefCountZero?: boolean; + resetOnComplete?: boolean | (() => Observable); + resetOnError?: boolean | ((error: any) => Observable); + resetOnRefCountZero?: boolean | (() => Observable); } export declare function shareReplay(config: ShareReplayConfig): MonoTypeOperatorFunction;