trunk
trunk copied to clipboard
Promise in `inline_js`
I realize that this is wasm_bindgen question, but I'm interested in the value of a Promise after it resolves.
#[wasm_bindgen(inline_js = "export function load_my_account() {\
window.account.load().then(result => sendMeToYew);
return true; \
}")]
extern "C" {
fn load_my_account() -> bool;
}
Is there a simple way to do this? Using a callback to the yew App perhaps?
Hey there @fredfortier. There are a few different ways to handle this. None of them really have anything to do with Trunk however haha :). No worries either way.
The pattern I would probably choose would be pass a callback into that JS function which can be called once the promise resolves on the JS side. There are definitely other patterns, some better than others depending on the use case.
Keep me posted! Hopefully Trunk is offering some usefulness in your project. Cheers
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.