question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Two-way bindings between Webview and Rust Yew

See original GitHub issue

How can i call the invoke_handler from a Yew application? I want to communicate between Yew and Webview. I already tried adding javascript to Yew through stdweb and then calling external.invoke("foo"). But this doesn’t work.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
hobofancommented, May 3, 2020

I also took a stab at it (taking a lot of inspiration from the discussed approach): https://github.com/hobofan/yew_webview_bridge (also available on crates.io)

A few notable points:

  • On the yew-side, I packaged the core logic into a service, which I think is a bit more of a idiomatic approach for yew
  • How the user wants to handle their “shared” message types is left up to them
  • The communication logic internally uses a Message wrapper type which carries a subscription_id and message_id, which allows for association of responses to their initial messages (this is handled by the service)
  • When you use .send_message from yew, it returns a MessageFuture with the response from web-view (which can be used to trigger a component update with the included send_future helper).
2reactions
mbuscemicommented, Apr 26, 2020

Putting this here for anyone who might find this in the future: https://github.com/mbuscemi/webview-yew-minimal

Read more comments on GitHub >

github_iconTop Results From Across the Web

web-view - crates.io: Rust Package Registry
It supports two-way bindings for communication between the Rust backend and JavaScript frontend. It uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and ...
Read more >
Tutorial | Yew
In this hands-on tutorial, we will take a look at how we can use Yew to build web applications. Yew is a modern...
Read more >
What's the state of Rust GUIs? : r/rust - Reddit
Real different you should be talking about 1/2 way bindings, uni-directional flows, flux, MVC, MVVC, MVP and many other acronyms. Those can't ...
Read more >
Rust libraries | Everything I know - My Knowledge Wiki
Rustea - Easy-to-use TUI crate for Rust, based off of the Elm ... Wry - Cross-platform WebView library in Rust for Tauri. webkit2gtk...
Read more >
Moxie: Incremental Declarative UI in Rust - Hacker News
Any discussion about incremental UI should include Yaron Minsky's talk about Jane Street's OCaml framework, incr_dom from 2016: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found