Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tell if clockface is visible app

ANSWERED

Hi, 

Does anyone know how to determine whether the clockface is the 'active' / current application or not?

Many thanks.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@Gondwana wrote:

This matches my observations. You kinda get an on_start event because your code is completely re-run when the other app is closed. Plus, you only get ontick events while your clockface is running (but that doesn't help you with knowing when it's closing). I found it necessary to save any local state info as soon as the state was changed since you won't get notified when you need to do it. Then, that state info (if any) needs to be loaded when your clockface (re)starts.


I stumbled onto this snippet while searching -- might be a good place to save state instead of doing it every time state changes.  I haven't tested it yet.  Also, was trying to hook into load/ready events to help defer loading of things as they were slowing down load time, but the best I have now is a setInterval to a function with a bit of a delay to give the app time to load before being called. 

 

import { me } from "appbit";

// register for the unload event
me.onunload = () => {
    console.log("We're about to exit");
}

 

View best answer in original post

Best Answer
3 REPLIES 3

@SunsetRunner wrote:

Hi, 

Does anyone know how to determine whether the clockface is the 'active' / current application or not?

Many thanks.


The behavior I've been seeing while testing is that any time another app is opened, the clockface is closed.  There might be an event you can hook to detect when closing -- maybe it's there and I'm missing it, but event/app lifecycle documentation would be helpful that detail all the events we can plug into.

 

The clockface doesn't seem to be closed when simply scrolling through the UI.  Also, the clockface is relaunched when say exiting an app and going back to the menu, even if the clockface is not visible.  (So, not exactly sure if there's a way to tell if it's visible, but if the clockface is running it seems another app is NOT.)  Again, these are just observed behaviors.

 

Best Answer
0 Votes

This matches my observations. You kinda get an on_start event because your code is completely re-run when the other app is closed. Plus, you only get ontick events while your clockface is running (but that doesn't help you with knowing when it's closing). I found it necessary to save any local state info as soon as the state was changed since you won't get notified when you need to do it. Then, that state info (if any) needs to be loaded when your clockface (re)starts.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@Gondwana wrote:

This matches my observations. You kinda get an on_start event because your code is completely re-run when the other app is closed. Plus, you only get ontick events while your clockface is running (but that doesn't help you with knowing when it's closing). I found it necessary to save any local state info as soon as the state was changed since you won't get notified when you need to do it. Then, that state info (if any) needs to be loaded when your clockface (re)starts.


I stumbled onto this snippet while searching -- might be a good place to save state instead of doing it every time state changes.  I haven't tested it yet.  Also, was trying to hook into load/ready events to help defer loading of things as they were slowing down load time, but the best I have now is a setInterval to a function with a bit of a delay to give the app time to load before being called. 

 

import { me } from "appbit";

// register for the unload event
me.onunload = () => {
    console.log("We're about to exit");
}

 

Best Answer