KyleAMathews / react-autoupdate-time

Renders a <time> element that autoupdates at a configurable interval
MIT License
19 stars 4 forks source link

Throttle for dates older than 24hours? #2

Open KingScooty opened 9 years ago

KingScooty commented 9 years ago

For pages with lots of records, it'd be nice to squeeze some perf out of this by throttling the interval time for dates that are older than 24hours.

Perhaps even disabling the interval for autoupdate time components that are older than 24hours, as i doubt someone's going to sit on the page for an entire day (but just incase, enable it as a parameter).

KyleAMathews commented 9 years ago

I like this. Perhaps tie the interval time to the time intervals used by moment.js to choose the output string e.g. this component updates every few seconds until 90 seconds and then every ~30 seconds until 45 minutes, then every minute until 24 hours, then only once an hour to 25 days, then once a day from then on. Perhaps make it possible to turn off on components older than 24 hours but I'd vote no as I've written apps where people would leave the apps open for weeks at a time. It's easy enough to manually disable updates so the internal logic should be fairly conservative.

I'm not using this component so much anywhere that I'm worrying about performance so won't be writing the patch anytime soon but I'd be happy to merge a PR.