8

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.

Mike Raven
  • 2,133
  • 2
  • 23
  • 36

2 Answers2

5

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.

Skip Sauls
  • 2,580
  • 18
  • 14
4

Here is a good example of setInterval. I found it helpful.

Calling Apex method at regular interval from Lightning Component