mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-21 20:22:14 +00:00
Readme tweaks (#606)
* Use ES modules in README example * Remove introduction blog post from README While the blog post is great, the README and the guide should be a good enough intro to wasm-bindgen, and are more likely to be kept up to date.
This commit is contained in:
parent
c4dcaee1b9
commit
ae7a9a7394
20
README.md
20
README.md
@ -4,11 +4,6 @@
|
|||||||
|
|
||||||
**Facilitating high-level interactions between wasm modules and JavaScript.**
|
**Facilitating high-level interactions between wasm modules and JavaScript.**
|
||||||
|
|
||||||
[Introduction blog post: "JavaScript to Rust and Back Again: A `wasm-bindgen` Tale"][post]
|
|
||||||
|
|
||||||
[host]: https://github.com/WebAssembly/host-bindings
|
|
||||||
[post]: https://hacks.mozilla.org/2018/04/javascript-to-rust-and-back-again-a-wasm-bindgen-tale/
|
|
||||||
|
|
||||||
[](https://travis-ci.org/rustwasm/wasm-bindgen)
|
[](https://travis-ci.org/rustwasm/wasm-bindgen)
|
||||||
[](https://ci.appveyor.com/project/alexcrichton/wasm-bindgen)
|
[](https://ci.appveyor.com/project/alexcrichton/wasm-bindgen)
|
||||||
[](https://crates.io/crates/wasm-bindgen)
|
[](https://crates.io/crates/wasm-bindgen)
|
||||||
@ -17,8 +12,6 @@
|
|||||||
|
|
||||||
Import JavaScript things into Rust and export Rust things to JavaScript.
|
Import JavaScript things into Rust and export Rust things to JavaScript.
|
||||||
|
|
||||||
`src/lib.rs`:
|
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#![feature(use_extern_macros)]
|
#![feature(use_extern_macros)]
|
||||||
|
|
||||||
@ -39,17 +32,12 @@ pub fn greet(name: &str) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Use exported Rust things from JavaScript!
|
Use exported Rust things from JavaScript with ECMAScript modules!
|
||||||
|
|
||||||
`index.js`:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Asynchronously load, compile, and import the Rust's WebAssembly
|
import { greet } from "./hello_world";
|
||||||
// and JavaScript interface.
|
|
||||||
import("./hello_world").then(module => {
|
greet("World!");
|
||||||
// Alert "Hello, World!"
|
|
||||||
module.greet("World!");
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Guide
|
## Guide
|
||||||
|
Loading…
x
Reference in New Issue
Block a user