Skip to content
Snippets Groups Projects
Verified Commit 51548c51 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

refactor: improved type handing in wasm engine

parent 1f7e57e8
No related branches found
No related tags found
No related merge requests found
Pipeline #2224 canceled
...@@ -549,7 +549,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { ...@@ -549,7 +549,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
get wasmEngine(): string | null { get wasmEngine(): string | null {
if (!this.gameBoy) return null; if (!this.gameBoy) return null;
return this.gameBoy.get_wasm_engine_ws(); return this.gameBoy.get_wasm_engine_ws() ?? null;
} }
get framerate(): number { get framerate(): number {
......
...@@ -322,15 +322,15 @@ impl GameBoy { ...@@ -322,15 +322,15 @@ impl GameBoy {
self.ppu().set_palette_colors(&palette); self.ppu().set_palette_colors(&palette);
} }
pub fn get_wasm_engine_ws(&self) -> String { pub fn get_wasm_engine_ws(&self) -> Option<String> {
let dependencies = dependencies_map(); let dependencies = dependencies_map();
if !dependencies.contains_key("wasm-bindgen") { if !dependencies.contains_key("wasm-bindgen") {
return String::from("-"); return None;
} }
String::from(format!( Some(String::from(format!(
"wasm-bindgen/{}", "wasm-bindgen/{}",
*dependencies.get("wasm-bindgen").unwrap() *dependencies.get("wasm-bindgen").unwrap()
)) )))
} }
fn js_to_pixel(value: &JsValue) -> Pixel { fn js_to_pixel(value: &JsValue) -> Pixel {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment