I have to implement the JS function setTimeout (and setInterval) and I have a problem with the first parameter of the function : the function to be called.
Here the code without the implementation of the timer:
public int jsFunction_setTimeout(Object function, int time){
final Scriptable scopee = this.js.getScope();
Context context = Context.enter();
//Object result = context.evaluateString(scopee, function, "<cmd>", 1, null);
//String value = Context.toString(result);
//System.out.println(value);
Context.exit();
}
When I enter :
window.setTimeout(function f(){console.log("hey");}, 10000)
, I have some functions which bring me to this function.
The type of the var function is : 'org.mozilla.javascript.gen.c1@6537cf78'. How can I execute this variable with rhino ?
I have to execute a JS function in order to execute an another one but how Rhino can execute the second function ?
I tried to change the type of the var (String function) but it's not work because function f(){[...]} isn't a String.
Thanks in advance !