Skip to content

Commit

Permalink
docs(ThrottleConfig): document "leading" and "trailing" behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Jan 31, 2023
1 parent 2c8a649 commit f9cdf18
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
35 changes: 30 additions & 5 deletions src/internal/operators/throttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@ import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { innerFrom } from '../observable/innerFrom';

/**
* An object interface used by {@link throttle} or {@link throttleTime} that ensure
* configuration options of these operators.
*
* @see {@link throttle}
* @see {@link throttleTime}
*/
export interface ThrottleConfig {
/**
* If `true`, the resulting Observable will emit the first value from the source
* Observable at the **start** of the "throttling" process (when starting an
* internal timer that prevents other emissions from the source to pass through).
* If `false`, it will not emit the first value from the source Observable at the
* start of the "throttling" process.
*
* If not provided, defaults to: `true`.
*/
leading?: boolean;
/**
* If `true`, the resulting Observable will emit the last value from the source
* Observable at the **end** of the "throttling" process (when ending an internal
* timer that prevents other emissions from the source to pass through).
* If `false`, it will not emit the last value from the source Observable at the
* end of the "throttling" process.
*
* If not provided, defaults to: `false`.
*/
trailing?: boolean;
}

Expand Down Expand Up @@ -48,11 +73,11 @@ export interface ThrottleConfig {
* @see {@link sample}
* @see {@link throttleTime}
*
* @param durationSelector A function
* that receives a value from the source Observable, for computing the silencing
* duration for each source value, returned as an Observable or a Promise.
* @param config a configuration object to define `leading` and `trailing` behavior. Defaults
* to `{ leading: true, trailing: false }`.
* @param durationSelector A function that receives a value from the source
* Observable, for computing the silencing duration for each source value,
* returned as an `ObservableInput`.
* @param config A configuration object to define `leading` and `trailing`
* behavior. Defaults to `{ leading: true, trailing: false }`.
* @return A function that returns an Observable that performs the throttle
* operation to limit the rate of emissions from the source.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/internal/operators/throttleTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { timer } from '../observable/timer';
* internally by the optional `scheduler`.
* @param scheduler The {@link SchedulerLike} to use for
* managing the timers that handle the throttling. Defaults to {@link asyncScheduler}.
* @param config a configuration object to define `leading` and
* @param config A configuration object to define `leading` and
* `trailing` behavior. Defaults to `{ leading: true, trailing: false }`.
* @return A function that returns an Observable that performs the throttle
* operation to limit the rate of emissions from the source.
Expand Down

0 comments on commit f9cdf18

Please sign in to comment.