If I have a JavaScript function like the one below, I understand that I must call Engine.Execute(ScriptText) from the Host to both load and execute the code.
The reason I am asking is that my app will include a bunch of host object loaded into an engine then one (or more) user written scripts. All are loaded into the same engine using Execute. The user then develops their script and presses a Run button to load and execute their piece of the puzzle. After executing, the user may want to edit the script and update the engine with the changes but without reloading the entire engine (don't want to reload all the host objects and other support scripts etc.). The executed (executing) script is very stateful and updates itself and its variables through callbacks and interfacing with other dynamic systems so I want to preserve state as much as possible.
How can I let the user edit a script that has been executed without reloading the entire script and host objects?
function foo() {
console.log("some message");
}
What happens if I call Engine.Execute(ScriptText) a second time on the same engine with a different string in console.log()? Is there a duplicate foo() function in my script?The reason I am asking is that my app will include a bunch of host object loaded into an engine then one (or more) user written scripts. All are loaded into the same engine using Execute. The user then develops their script and presses a Run button to load and execute their piece of the puzzle. After executing, the user may want to edit the script and update the engine with the changes but without reloading the entire engine (don't want to reload all the host objects and other support scripts etc.). The executed (executing) script is very stateful and updates itself and its variables through callbacks and interfacing with other dynamic systems so I want to preserve state as much as possible.
How can I let the user edit a script that has been executed without reloading the entire script and host objects?