Examples
Each page on this section demonstrates the examples compiled as WASM applications. Each example needs to first be compiled before the page will successfully display the example.
You may compile all examples for WASM before visiting the pages using the following command:
for example in $(ls examples)
do wasm-pack build --target web --out-dir "../../doc/src/pkg" "examples/${example}"
done
Note:
To run examples natively, run:
cargo run --package <example_name>`
This differs from the usual
--example
parameter as individualCargo.toml
files are used to specify the dependencies relevant to that example.
Event Loop
Counts down from 10, writing output to the console.
To run this example locally, run:
cargo run --package event_loop
For WASM:
wasm-pack build --target web --out-dir ../../doc/src/pkg examples/event_loop
Open the browser console to see the output of this application.
Event Loop Console
Counts down from 100, writing to the console on the same line.
To run this example locally, run:
cargo run --package event_loop_console
For WASM:
wasm-pack build --target web --out-dir ../../doc/src/pkg examples/event_loop_console
Terminal:
Event Loop Rate Limit
Counts down from 1_000_000
as fast as possible, refreshing the screen at 10 FPS.
To run this example locally, run:
cargo run --package event_loop_rate_limit
For WASM:
wasm-pack build --target web --out-dir ../../doc/src/pkg examples/event_loop_rate_limit
Terminal: