Skip to content

Instantly share code, notes, and snippets.

@pegli
Last active December 16, 2015 21:59
Show Gist options
  • Save pegli/5503830 to your computer and use it in GitHub Desktop.
Save pegli/5503830 to your computer and use it in GitHub Desktop.
pass a native function call to a KrollFunction invocation
var MyModule = require('com.obscure.module');
var proxy = MyModule.createMyProxy();
proxy.foogle(function(cb) {
cb('hello, world!');
});
E/JNIUtil ( 681): !!! Unable to convert unknown Java object class 'com.obscure.MyProxy$1$1' to Js value !!!
public void doSomething() {
}
@Kroll.method
public void foogle(KrollFunction callback) {
final MyProxy self = this;
callback.call(this.getKrollObject(), new Object[] {
new KrollFunction() {
public Object call(KrollObject krollObject, Object[] args) {
self.doSomething();
}
}
/* the rest of the KrollFunction methods elided */
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment