var speed = 0.5;
function move(arg) {
// do something with arg
}
I am trying to create a robot object in the webbrowser that is connected to the device via UART, such that robot.speed translate into a call to UART.eval('speed'), and robot.move(value) translate to call to UART.eval('move(value)'). But in a generic way, so that the object robot does not really have the properties speed and move and any other properties could be called without defining them explicitly, hence the use of Proxy as per Gordon suggestion.
Check again the first few posts for more details. I hope that makes some sense.
==
I might have found a way around my problem with an additional call eval('typeof prop') to check if the property exist and is a function or not.
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.
Thanks @Robin
Imagine we have this code on the device:
I am trying to create a
robot
object in the webbrowser that is connected to the device via UART, such thatrobot.speed
translate into a call toUART.eval('speed')
, androbot.move(value)
translate to call toUART.eval('move(value)')
. But in a generic way, so that the objectrobot
does not really have the propertiesspeed
andmove
and any other properties could be called without defining them explicitly, hence the use of Proxy as per Gordon suggestion.Check again the first few posts for more details. I hope that makes some sense.
==
I might have found a way around my problem with an additional call
eval('typeof prop')
to check if the property exist and is a function or not.