Skip to content

Commit

Permalink
Update docs for the Rust-generated wasm function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
epompeii authored Aug 13, 2020
1 parent 9f9634c commit e0dae8e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ pub fn run() -> Result<(), JsValue> {
}
```

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

```js
import("../crate/pkg").then(module => {
module.run();
});
import("../pkg/index.js")
.then((module) => {
module.main_js();
})
.catch(console.error);
```

## Run The Project
Expand Down

0 comments on commit e0dae8e

Please sign in to comment.