Skip to content

Commit e0dae8e

Browse files
authored
Update docs for the Rust-generated wasm function
The documentation is out of date. It says that there should be a `run()` function, but really a `main_js()` function should be there. However, the `rust-webpack-template` doesn't add the `then()` statement to the import in the template. I have created [a pull request](rustwasm/rust-webpack-template#172) to add this to the template, and I have updated the docs for this newer version here.
1 parent 9f9634c commit e0dae8e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/src/tutorials/hybrid-applications-with-webpack/using-your-library.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ pub fn run() -> Result<(), JsValue> {
5555
}
5656
```
5757

58-
Now, open up the `js/index.js` file. We see our Rust-generated wasm `run` function being
58+
Now, open up the `js/index.js` file. We see our Rust-generated wasm `main_js` function being
5959
called inside our JS file.
6060

6161
```js
62-
import("../crate/pkg").then(module => {
63-
module.run();
64-
});
62+
import("../pkg/index.js")
63+
.then((module) => {
64+
module.main_js();
65+
})
66+
.catch(console.error);
6567
```
6668

6769
## Run The Project

0 commit comments

Comments
 (0)