1 unstable release
0.1.0 | Feb 26, 2023 |
---|
#28 in #web-worker
5KB
72 lines
Launch web worker
Highly WIP. Current usage:
fn startup() {
let worker = worker_from_runner("MyRunner", "my_pkg_name").unwrap();
}
#[wasm_bindgen]
pub struct MyRunner;
#[wasm_bindgen]
impl MyRunner {
pub fn new() -> Self {
Self
}
pub fn init(&self) {
console::log_1(&JsValue::from_str("MyRunner initialized"));
}
pub fn onmessage(&mut self, msg: MessageEvent) {
console::log_1(&format!("MyRunner received: {msg:?}").into());
}
}
Dependencies
~7.5–10MB
~181K SLoC