You are reading a single comment by @randunel and its replies. Click here to read the full conversation.
  • Nice solution, Bogdan. I would improve it to allow passing params from one to another, so you would not need to use globals. This does degrade readability though:

    
    function setupBTN1(customParams) {
      return function() {
        function test() {
          return callback();
        }
        var id = setWatch(test, BTN1, {repeat:false, edge:"rising"});
        function callback() {
          console.log('Hello! watch id was', id, 'and customParams was', customParams);
          clearWatch(id);
          setTimeout(setupBTN1(customParams + Math.random()), 1000);
        }
      };
    }
    setupBTN1(0)();
    
About

Avatar for randunel @randunel started