From 51548c51c7305b14bc02bef09b986b2e58ebdb50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Tue, 21 Feb 2023 18:26:42 +0000
Subject: [PATCH] refactor: improved type handing in wasm engine

---
 frontends/web/ts/gb.ts | 2 +-
 src/gb.rs              | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts
index 4e82177b..f376320f 100644
--- a/frontends/web/ts/gb.ts
+++ b/frontends/web/ts/gb.ts
@@ -549,7 +549,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
 
     get wasmEngine(): string | null {
         if (!this.gameBoy) return null;
-        return this.gameBoy.get_wasm_engine_ws();
+        return this.gameBoy.get_wasm_engine_ws() ?? null;
     }
 
     get framerate(): number {
diff --git a/src/gb.rs b/src/gb.rs
index b6394104..8f7074d8 100644
--- a/src/gb.rs
+++ b/src/gb.rs
@@ -322,15 +322,15 @@ impl GameBoy {
         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();
         if !dependencies.contains_key("wasm-bindgen") {
-            return String::from("-");
+            return None;
         }
-        String::from(format!(
+        Some(String::from(format!(
             "wasm-bindgen/{}",
             *dependencies.get("wasm-bindgen").unwrap()
-        ))
+        )))
     }
 
     fn js_to_pixel(value: &JsValue) -> Pixel {
-- 
GitLab