Im trying to pass a wasm-bindgen closure to a JS class that will call it when there are updates. The Closure needs to live for the duration of the program so it is not invalidated at the end of the component execution. I though I would use use_state to hold the Closure but I keep getting errors:
error[E0507]: cannot move out of dereference of `UseStateHandle<wasm_bindgen::prelude::Closure<dyn FnMut(wasm_bindgen::JsValue)>>`
--> src/main.rs:32:21
|
32 | let f = *f;
| ^^ move occurs because value has type `wasm_bindgen::prelude::Closure<dyn FnMut(wasm_bindgen::JsValue)>`, which does not implement the `Copy` trait
I tried wrapping it in Cell and Arc but get similar errors. What can I do to get the Closure to outlive the component?