Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java setTimeout #406

Closed
tanpuer opened this issue Jul 3, 2018 · 4 comments
Closed

Java setTimeout #406

tanpuer opened this issue Jul 3, 2018 · 4 comments

Comments

@tanpuer
Copy link

tanpuer commented Jul 3, 2018

v8.registerJavaMethod(new JavaVoidCallback() {
@OverRide
public void invoke(final V8Object receiver, final V8Array parameters) {
if (parameters.length() == 2){
final Object timeout = parameters.get(1);
final Object callback = parameters.get(0);
if (!(timeout instanceof Integer) || !(callback instanceof V8Function)){
return;
}
// ((V8Function)callback).call(receiver, null);
new Handler().postDelayed(new Runnable() {
@OverRide
public void run() {
((V8Function)callback).call(receiver,null);
}
},(int)timeout);
}
}
},"setTimeout");

if i call the v8Function immediately, it did work. But if i call the function after some time, the V8Function will be released automatically. Can I hold the v8Function and release it later myself?

@tanpuer tanpuer closed this as completed Jul 3, 2018
@carl1990
Copy link

+1
face same problem

@huhuang03
Copy link

Same issue, any idea?

@Unicellular-SU
Copy link

use v8Function.twin()

@SamukaDEV
Copy link

how? @Unicellular-SU

you can explain? or send an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants