You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi Martin,

    Yes - it should be possible. The issue is probably with what happens to the this variable when called from setInterval. It's a standard JS thing...

    You could try something like this:

    Clock.prototype.start = function() {
      var me = this;
      setInterval(function() { me.tick(); },1000);
    }
    

    This will define a function for each setInterval, but it'll be relatively small.

    I'm not sure quite what you're planning, but I wonder how many clock modules a user might have? If it's 1 or 2 it might not matter if the function is duplicated.

About

Avatar for Gordon @Gordon started