Do you need polling but only as long as a certain component is visible? If so, then the TimerExtension Add-on is the solution for you.
Simply start the polling and then either stop the polling manually or just detach the component or a parent of it and the polling stops automatically.
The extension is implemented using JavaScript, so no WidgetSet compilation is necessary.