You are reading a single comment by @ChristianW and its replies. Click here to read the full conversation.
  • Hi @allObjects, I just refactored the whole code and changed every object - except Velo which is dynamically created and I don't know how that works in the way you suggested.

    However, I ran into an issue. Look at this simple example:

    var Obj = {
        message: "foo",
    
        init: function() {
            setInterval(this.log, 1000);
        },
    
        log: function() {
            console.log(this.message);
        }
    };
    
    Obj.init();
    
    undefined
    undefined
    undefined
    …
    

    The interval output is just undefined and not foo as you would expect.
    Somehow passing the callback this.log to setInterval() loses the object context.

    Can you explain this or do you have any solution for this other than using Obj.message instead of this.message inside the log() method?
    Passing Obj.log as callback does not help by the way...

    Very strange.

About

Avatar for ChristianW @ChristianW started