-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(throttle): properly handle default ThrottleConfig values #7176
fix(throttle): properly handle default ThrottleConfig values #7176
Conversation
e1f706f
to
f9cdf18
Compare
@@ -47,15 +47,15 @@ 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. | |||
*/ | |||
export function throttleTime<T>( | |||
duration: number, | |||
scheduler: SchedulerLike = asyncScheduler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should throttleTime
merge scheduler
and config
parameters effectively introducing a ThrottleTimeConfig
interface which would extend ThrottleConfig
interface by adding scheduler?: SchedulerLike
property to it?
It would effectively remove the need to use throttleTime
like this: throttleTime(1000, undefined, { trailing: true })
to throttleTime(1000, { trailing: true })
.
@benlesh, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should probably be throttleTime(number, config)
where config
has a scheduler
option. We'll need to deprecate the other signatures that take a scheduler as the second argument, but allow the scheduler to be passed with the config.
* fix(throttle): properly handle default ThrottleConfig values * docs(ThrottleConfig): document "leading" and "trailing" behavior (cherry picked from commit b7a4e94)
Description:
This PR is split into two commits. The first one fixes an issue described in #7146, while the second one adds
ThrottleConfig
docs.This issue should be probably cherry picked to the
7.x
branch.Related issue (if exists):
Fixes #7146