How can call some function every 4 minutes if page is active or not(if page is under for example 5 pages in stack of pages)


I want to run a function every 5 seconds once on one of the pages, even if the user is not on that page and goes to another page.
I do not want to repeat this function on all pages. I want, for example, to always run one of the pages at the bottom of the page stack. As I can do this, my goal is to create a process for refreshing access_token.


I think this is a fatally flawed design. Pages are responsible for interacting with users. Leaving aside my disdain for blanket periodic tasks in general, all interaction with the network such as refreshing access tokens should be done in service providers, not pages, at which point your question is mooted.


yes i put this responsibility in auth service but i need some trigger to this function . I implemented some interval function which calls this function every 4 minutes . is there any simple and optimized way to to this?tnx