Stream: wit-bindgen

Topic: Create bindings from rust code


view this post on Zulip Hamza (Jul 10 2022 at 10:36):

Hi, I'm thinking of using wit to export a Rust API from one crate and import it in another. The API is the Yew components. I would like to have a WASM package that exports those components and another package that imports them. Is it possible?

Example of component: https://github.com/yewstack/yew/blob/5570710cdf88658877b0ddc41e4b531cd7bdc7e6/examples/counter_functional/src/main.rs
cargo expand output: https://gist.github.com/hamza1311/61aaa9974825574ff066a3169de3b677

When importing, the BaseComponent impl is needed so it can be consumed: https://api.yew.rs/next/yew/virtual_dom/struct.VComp.html#method.new

I don't have a need for it right now but it's something that I can see being useful. Regardless, I wanted to try this out

Rust / Wasm framework for building client web apps - yew/main.rs at 5570710cdf88658877b0ddc41e4b531cd7bdc7e6 · yewstack/yew
cargo expand of functional_counter Yew example. GitHub Gist: instantly share code, notes, and snippets.

Last updated: Dec 23 2024 at 12:05 UTC