• Hi everybody,
    I have this code:

    clearWatch();
    setWatch(() => {
      console.log('\-----');
      console.log('BTN3');
      btn3Handler()
    }, BTN3, {
      debounce: DEBOUNCE,
      repeat: true,
      edge: "falling"
    });
    setWatch(() => {
      console.log('BTN4');
      btn4Handler()
    }, BTN4, {
      debounce: DEBOUNCE,
      repeat: true,
      edge: "falling"
    });
    

    When I press BTN3 I get often (not always) get this in console:

    \----
    BTN3
    BTN4
    

    It looks like BTN4 fires together with BTN3.

    The only workaround I found is this ugly one (clear watches before calling the handler and reattach them after):

    clearWatch();
    setWatch(() => {
      console.log('-----');
      console.log('BTN3');
      clearWatch();
      btn3Handler();
      addWatch();
    }, BTN3, {
      debounce: DEBOUNCE,
      repeat: true,
      edge: "falling"
    });
    setWatch(() => {
      console.log('BTN4');
      btn4handler();
    }, BTN4, {
      debounce: DEBOUNCE,
      repeat: true,
      edge: "falling"
    });
    

    The issue doesn't happen in the emulator, just on the real clock.

    This is the gist with the complete code (the issue is at line 119):
    https://gist.github.com/fbedussi/05f7bee30cf7fbc43a3dbfa728c5edb2

    Is this a bug or am I missing something?

    thanks and kudos for the project!

About

Avatar for fbedussi @fbedussi started