react-async-poll's People
Forkers
mxstbr carboes jason-curtis xelmedia ixpertasolutions sojimaxi iliaznk raphaelboukara numanhassan vargentumreact-async-poll's Issues
slow down/stop polling when window is not visible
To reduce load on the system being polled (and the ones doing the polling), it'd be great to be able to slow down/stop polling while the window is not visible.
This should be feasible using the Page Visibility API which is now implemented in modern browsers.
Suggested changes:
asyncPoll
now takes a third argument:asyncPoll(intervalDuration, component, hiddenIntervalDuration)
wherehiddenIntervalDuration
is the duration to use whendocument.visibilityState
ishidden
.- the tricky part is how to behave when
document.visibilityState
changes. The important edge case here is that if the page is hidden and we have a slow timeout, but then the page becomes visible, we should either poll immediately or wait a little longer and then poll. The airtight way to do this would include storing athis.lastPolled
timestamp, so that whendocument.visibilityState
changes, we can set a timeout with the remaining interval according to the currently correctintervalDuration
. In some cases (if we switched from a slower interval to a faster interval, and the faster interval says we should have already polled) the new timeout would fire immediately after which we'd settle back in to the regularsetInterval
situation.
There could also be a simpler approach to this, where whenever document.visibilityState
changes, we simply poll right then and then carry on with the appropriate interval.
The status of polling
I think it really cool if we know about the status of polling, e.g.:
this.keepPolling
- true
or false
in current moment
Thank you :)
Instead of hard coded poll interval, can I pass the interval as props?
I need to to use the react-async-poll in two different places with different poll intervals. Currently, I have to write two different wrappers with different poll intervals. Can I pass the poll interval as props?
Stop polling make unable to restart it
When you want to stop polling and call the "stopPolling" method, your cannot restart it.
The issue comes up because the "interval" property isn't set to undefined (line 29)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.