-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to import and extend JS classes #210
Comments
Agreed this'd be great to have! I'm not 100% sure what this would look like, but would love to see and help explore options here |
Cool! I'll do some research into how this can be done. I've already looked at bindgen for C++ and didn't find an immediate solution. |
Is there a way to expand (procedural) macros to see the text output of |
cargo-expand should do the trick.
|
Thanks @jsheard. I think I have it working now. |
This is the first time diving into something like this, so this may be a naive suggestion. It looks like a class is imported as a Note I've added JS:
Generated Rust:
Rust usage:
|
Any updates on this? I was looking to see how feasible it would be to create webcomponents using wasm as an experiment, but it's necessary to extend classes for that (either |
@jhpratt no updates; you may be interested in reading the discussion in rustwasm/team#162 however. |
A couple links to what led me here.
It would be really amazing to be able to extend the Each AudioWorkletProcessor is its own thread, and having one of those exist in the wasm sphere would ~10x the audio-synthesis ceiling (+/-). The issue is that one must extend AudioWorkletProcessor and re-export it in order to use it in wasm.... so web audio will have to wait once more. |
For anyone still looking for the Audio Worklet functionality there is some documentation on how to do it here: https://rustwasm.github.io/wasm-bindgen/examples/wasm-audio-worklet.html |
- Since wasm-bindgen doesn't support a way to extend JavaScript classes (rustwasm/wasm-bindgen#210), add a basic JavaScript shim, that pushes the data available in Rust to the Readable in JavaScript. - use channels and spawn_local in Rust to move along Stream iterator and pass results to enqueue for read() (in the JavaScript shim) - adds an abort controller that will abort the stream in JavaScript is a stream error occurs in Rust
- Since wasm-bindgen doesn't support a way to extend JavaScript classes (rustwasm/wasm-bindgen#210), add a basic JavaScript shim, that pushes the data available in Rust to the Readable in JavaScript. - use channels and spawn_local in Rust to move along Stream iterator and pass results to enqueue for read() (in the JavaScript shim) - adds an abort controller that will abort the stream in JavaScript is a stream error occurs in Rust
- Since wasm-bindgen doesn't support a way to extend JavaScript classes (rustwasm/wasm-bindgen#210), add a basic JavaScript shim, that pushes the data available in Rust to the Readable in JavaScript. - use channels and spawn_local in Rust to move along Stream iterator and pass results to enqueue for read() (in the JavaScript shim) - adds an abort controller that will abort the stream in JavaScript is a stream error occurs in Rust
JS classes are heavily used building block in UI development.
It's common for a library like ReactJS or Polymer to provide a component class to extend from.
Thus, there should be an easy way to interoperate with classes, extend them in Rust, and export them back to JS.
I don't know about Rust to know what's possible yet. But I imagine we could use attributes to annotate when a Rust struct inherits from a JS class?
The text was updated successfully, but these errors were encountered: