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:
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...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
The interval output is just
undefined
and notfoo
as you would expect.Somehow passing the callback
this.log
tosetInterval()
loses the object context.Can you explain this or do you have any solution for this other than using
Obj.message
instead ofthis.message
inside thelog()
method?Passing
Obj.log
as callback does not help by the way...Very strange.