Get existing Watches

Posted on
  • Is there any way to get a list of listeners created by setWatch()?

    I was thinking about creating a global listener, so it would be nice if it could do something like

    setWatch(()=>{
      // check only this function is listening
      if (getWatches(BTN1).length === 1) doCoolStuff();
    }, BTN1);
    

    And that would allow me to doCoolStuff by pressing BTN1 from e.g. most clocks, but without interfering with apps that actually use BTN1.

    And I guess the same question for Bangle.on()? (Because I just realized it would be neat to swipe from the clock to settings/launcher)

  • there is global['\xff'].watches array and the pin is there too so it is doable. However I'm not sure it is stable interface for getting list of watches.

  • Fri 2021.04.23

    While the instruction @fanoush provided in post #2 would most likely be the preferred method, from the WebIDE use of dump() also will provide that detail.

  • Thanks for the replies.
    That does sound like too much bother (for now), guess I'll just stick with a "try not to assign buttons that are already in use" message.

  • And I guess the same question for Bangle.on()?

    You can do similarly - with Bangle["#onfoobar"]

    But yes, while those haven't changed in a while there is no guarantee they won't change in the future.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Get existing Watches

Posted by Avatar for rigrig @rigrig

Actions