launch-worker

Crates.iolaunch-worker
lib.rslaunch-worker
version0.1.0
sourcesrc
created_at2023-02-26 21:22:18.811598
updated_at2023-02-26 21:22:18.811598
descriptionLaunch Wasm code in web workers
homepagehttps://github.com/sgasse/launch-worker
repositoryhttps://github.com/sgasse/launch-worker
max_upload_size
id795486
size4,919
(sgasse)

documentation

https://docs.rs/launch-worker/

README

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());
    }
}
Commit count: 3

cargo fmt