wasm-bindgen/examples/char
Frank Hassanabad 6561fba947 Applied eslint from main .eslintrc to examples (#418)
* Changed eslintrc to be JSON file (Most projects use JSON version)
  * Added .eslintignore to ingore node_modules from subdirectories such as examples
  * Ran eslint --fix examples to fix all examples
  * Added npm script for running eslint against examples
  * Added npm script for running eslint against generated *out* code
  * Hooked npm scripts into travis ci to prevent examples from becoming inconsistent with future PR's
2018-07-08 01:02:10 -05:00
..
src rustfmt all the things 2018-06-27 22:42:34 -07:00
.gitignore add char support (#206) 2018-05-22 12:34:41 -05:00
build.sh add char support (#206) 2018-05-22 12:34:41 -05:00
Cargo.toml add char support (#206) 2018-05-22 12:34:41 -05:00
chars.js Applied eslint from main .eslintrc to examples (#418) 2018-07-08 01:02:10 -05:00
index.html add char support (#206) 2018-05-22 12:34:41 -05:00
index.js Applied eslint from main .eslintrc to examples (#418) 2018-07-08 01:02:10 -05:00
package.json add char support (#206) 2018-05-22 12:34:41 -05:00
README.md add char support (#206) 2018-05-22 12:34:41 -05:00
webpack.config.js Applied eslint from main .eslintrc to examples (#418) 2018-07-08 01:02:10 -05:00

Char

This directory is an example of how the #[wasm_bindgen] macro will convert the rust char type to a single code-point js string.

You can build the example locally with:

$ ./build.sh

Opening your web browser should display a single counter with a random character for it's key and 0 for its count. You can click the + button to increase a counter's count. By clicking on the "add counter" button you should see a new counter added to the list with a different random character for it's key.

Under the hood javascript is choosing a random character from an Array of characters and passing that to the rust Counter struct's constructor so the character you are seeing on the page has made the full round trip from js to rust and back to js.