Event for when the app comes to the foreground (mobile)

When my web app (plain framework7, not Cordova) comes to the foreground I want to refresh a few views if its been dormant for a long time.

I have not been able to find an app event that is triggered when an app on mobile is brought to the foreground again.

Thanks! I suppose that will work. Is there a way to weave this into the framework7 event stream proper to have the component pages respond to it individually … or even at the app level.

What I intend to do is check if its been 2 hours since the app was brought to the foreground and then call refresh on two pages to update their photo streams from the database.

Here is a version without the time span check. It seems to be working as intended.

document.addEventListener("visibilitychange", function() {
  if (document.visibilityState === 'visible') {
  app.views.stories.router.refreshPage();
  app.views.profile.router.refreshPage();
  }
document.addEventListener("visibilitychange", function() {
  app.emit('visibilitychange', document.visibilityState)
}

And then, for example in some component you can listen for it like:

app.on('visibilitychange', (state) => {
  if (state === 'visible') ...
});