Open
Description
Hello,
It would be very helpful to have a 'hello world' style example of binding a native function into the JavaScript environment and returning a value. I've been able to do the former, but haven't succeeded in actually resolving the returned promise on the JavaScript side.
On the Rust side I have:
let wvc = wv.clone();
wv.bind("RustMethod", move |seq, content| {
println!("{}, {}", seq, content);
wvc.r#return(seq, 0, "{}");
});
On the JavaScript side I have tried a few variations on
document.addEventListener("DOMContentLoaded", function() {
RustMethod("foo").then(
(response) => {
console.log("Callback " + response);
},
(reject) => {
console.log("Rejection " + reject);
}
);
});
On the Rust side, the method is clearly invoked as evidenced by the println!() macro generating output. However, the promise returned by RustMethod seems to never resolve, suggesting that something is awry with the parameters passed to the return method.
Any pointer towards getting this to work would be much appreciated :-)
Metadata
Metadata
Assignees
Labels
No labels