Plugin onDisplay event

HI
If my plugin has forexample 5 min polling time, that menas that every time i switch to the page I need to wait while the 5 min elapsed?
How can we (in which event) manualy trigger the http get method, to fill the page and just at that moment start the countdown for next poll?

Decrease the polling interval & add a global variable to your plugin that stores the previous polling time. Then compare the current time with that previous poll time in your polling routine. If the difference is greater than 5 minutes, then actually send your HTTP request.

If you really want to limit your HTTP requests this is another function that can help.

Hey, thanks for the info…
However, this doesnt work for me…
Is it beacuse I am using pagebrowser?
Somehow, the poplling doesnt event start,…
I put a little check Polling function:

if (device.HasSubscribers() == false) {
console.log(“No subscribers”)
return;
}

but with this no polling is being started…

Using the pagebrowser deosn’t trigger the event when i switch between pages?

It’s compatible with PageBrowsers.

What event is triggered when user switches to a certain page?
Or we dont need to check this?
OnPoll function is running always? Independently of the page being opened or not?
How to achieve that the user will certainly have the content loaded from http whe he switches to a page? Like using this logic: user switches to a page we make one single request than the polling period should start. Is this a good solution?

If it is, how to catch the the page is actualy opened? Is it the onconnect function?

With the previous example i am getting “No subscribers” log message…

There is no page open event that the plugin can subscribe to. Decrease your polling interval & check HasSubscribers() in your plugin’s “onPoll” function. Decrease the PollingInterval to something like 250 milliseconds so that you can call that function every 250 ms.

Yeah…with low polling time it works ofcourse…unfortunatelly the server that i am requesting doesnt allow more than 6 requests/hour…so this means that every time the user switches to the page he sees a page with full of empty elements…
No workaround that you would suggest please?

You don’t have to poll your server every time onPoll is called. Again, like I said earlier. Store the actual server poll time in a variable & compare the current time with that. You can add another “if” statement in your code.