Skip to content

Commit

Permalink
Allow worker script URL to be specified in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
shamardy committed Mar 5, 2024
1 parent 7a8770c commit e97d49c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm2src/mm2_net/src/wasm_event_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub async fn handle_worker_stream(ctx: MmArc) {
"message": event.message(),
});

let worker = web_sys::Worker::new("worker.js").expect("Missing worker.js");
let script_url = ctx.conf["worker"].as_str().unwrap_or_else(|| "worker.js");

This comment has been minimized.

Copy link
@onur-ozkan

onur-ozkan Mar 5, 2024

Member

Moving this field under the event streaming configuration with a clearer name (like worker_path) would make more sense I think.

let worker = web_sys::Worker::new(script_url).expect("Missing worker.js");
let message_js = wasm_bindgen::JsValue::from_str(&data.to_string());

worker.post_message(&message_js)
Expand Down

0 comments on commit e97d49c

Please sign in to comment.