hobofan / yew_webview_bridge

2-way communication between yew and web-view
Apache License 2.0
5 stars 10 forks source link

Consider a trait for handle_yew_message #1

Open kellpossible opened 4 years ago

kellpossible commented 4 years ago

Would you consider having a trait for handle_yew_message which has an implementation for WebViewBuilder to reduce boilerplate?

web_view::builder()
    // all the other options
    .handle_yew_message(webview, arg, |message: String| {
            // If we return a Some(_), we send a response for this message
            Some(format!("Hello, {}", &message))
    })
    .run()
    .unwrap();
hobofan commented 4 years ago

Sure, I don't see why not!

One small drawback I see is that the handler could be silently replaced if someone calls .invoke_handler with a more generic handler later.