Feature Request: Allow consumer to control bucket ids
#10 opened on Jun 1, 2020
Repository metrics
- Stars
- (12 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
All timers are grouped into "buckets" that are identified by the ms parameter. Using the ms parameter as a bucket identifier can have undesired consequences.
My suggestion: add an extra id parameter and use it as bucket identifier instead of ms parameter.
Furthermore, I think this parameter should be required (it should not default to the value of ms).
Which would be a non-backwards-compatible change.
Since, as I understand, set-harmonic-interval was developed to be used by react-use, let me use react-use as an example.
Suppose you want to have 2 sets of components - numerous instances of <X/> and numerous instances of <Y/> - and:
- you want both
<X/>and<Y/>to update after the same interval (samemsparameter value) - but you don't necessarily want instances of
Xto update when instances ofYupdate
This is impossible with the current implementation, because buckets are created per ms parameter.
Hopefully the above explanation is sufficient but consider this example for completeness: https://codesandbox.io/s/tender-kepler-9r1j1?file=/src/App.js
The stoplights will harmonically change the light every 5 seconds.
The triggers will harmonically flash every 5 seconds as well.
But triggers will not start flashing until you press any of them.
And if it just so happens, that you push the trigger 100ms before the stoplights are about to change, the trigger indicators will be on only for that 100ms, while I'd expect them to be on for the first 5 seconds after triggering.