Add leading
and trailing
for throttle
like in lodash
#37
Labels
Milestone
leading
and trailing
for throttle
like in lodash
#37
Following this comment
To have more industry-like behaviour (lodash),
throttle
should provide options to indicate whethertarget
should be triggered on the leading and/or trailing edge of the timeout.If
leading
andtrailing
options aretrue
,target
is triggered on the trailing edge of the timeout only if the throttledsource
is triggered more than once during the timeout.If
timeout
is0
andleading
isfalse
,target
triggering is deferred until to the next tick, similar tosetTimeout
with a timeout of0
.throttled
should be triggered immediately, one timethrottled
should be triggered immediately with payload of1
and second time after 100ms with payload of3
throttled
should be triggered after 100ms, one timethrottled
should be triggered after 100ms, one time, with payload of3
(just like current behaviour)throttled
should be triggered on the next tick, one time (just like current behaviour)throttled
should be triggered immediately with payload of1
and second time after 150ms with payload of3
With combination
leading: false, trailing: false
—throttled
should not be triggered at allPlayground with lodash's throttle
The text was updated successfully, but these errors were encountered: