Closed twlite closed 2 weeks ago
Generally you don't need to replace the ipc_handler
you can just replace the data captured in the closure, for example:
struct MyData {};
let x = Rc::new(RefCell::new(None::<MyData>));
let x_c = x.clone();
let ipc_handler = || {
if let Some(my_data) = x_c.borrow() {
}
};
// some_logic
// then set data inside `x`
*x.borrow_mut() = Some(MyData {})
Is your feature request related to a problem? Please describe.
I'm unable to modify or replace the
ipc_handler
directly on an existingWebView
instance. While<WebViewBuilder>.with_ipc_handler(handler)
allows setting the handler during the building phase, I haven't found a way to change it afterwards, which limits flexibility when theipc_handler
needs to be updated dynamically.Describe the solution you'd like
I would like to have an option to replace or override the
ipc_handler
on an existingWebView
instance, allowing updates to the handler without needing to rebuild the entire WebView.Describe alternatives you've considered
I've reviewed the available documentation and attempted various approaches but couldn't find any method to achieve this. Rebuilding the WebView is possible, but it’s inefficient and not feasible in cases where the handler needs to be updated frequently.
Additional context
This feature would improve flexibility when managing IPC communication in a dynamic environment. Any pointers to a workaround, if available, would also be appreciated.