What's the best way to implement polling inside Lightning component. I'd like to update my component every 5-10 seconds, calling backend (i.e. Apex class) to obtain new data for rendering. Seems like there is no apex:actionPoller analogue in Lightning.
-
do you mean apex:actionPoller instead of apex:actionFunction?– Phil BJul 2, 2015 at 20:49
-
Yes, sure. Sorry for typo– Mike RavenJul 2, 2015 at 20:50
2 Answers
Is this truly a polling event, or could it handled via PushTopics? If it is based on the value changing on a record, consider using PushTopics.
For polling, setTimeout and setInterval work, just be sure to use $A.run when making calls to actions, etc.
Here is a good example of setInterval. I found it helpful.
Calling Apex method at regular interval from Lightning Component