From 43b098ddf80cbd82d4202afb08a2f7a43547633a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sat, 29 Oct 2022 02:28:41 +0100
Subject: [PATCH] refactor: renamed event

---
 examples/web/index.ts      | 11 ++++++++---
 examples/web/react/app.tsx |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/web/index.ts b/examples/web/index.ts
index 94712ccb..b680317e 100644
--- a/examples/web/index.ts
+++ b/examples/web/index.ts
@@ -230,8 +230,11 @@ class GameboyEmulator extends Observable implements Emulator {
                     this.gameBoy!.frame_buffer_eager(),
                     PixelFormat.RGB
                 );
-                this.trigger("frame");
                 lastFrame = this.gameBoy!.ppu_frame();
+
+                // triggers the frame event indicating that
+                // a new frame is now available for drawing
+                this.trigger("frame");
             }
         }
 
@@ -328,6 +331,10 @@ class GameboyEmulator extends Observable implements Emulator {
         // in case the restore (state) flag is set
         // then resumes the machine execution
         if (restore) this.resume();
+
+        // triggers the loaded event indicating that the
+        // emulator has finished the loading process
+        this.trigger("loaded");
     }
 
     // @todo remove this method, or at least most of it
@@ -913,8 +920,6 @@ class GameboyEmulator extends Observable implements Emulator {
         this.romData = data;
         this.romSize = data.length;
         this.cartridge = cartridge;
-
-        this.trigger("rom:loaded");
     }
 
     setLogicFrequency(value: number) {
diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx
index 5b171ac9..8bc482f3 100644
--- a/examples/web/react/app.tsx
+++ b/examples/web/react/app.tsx
@@ -135,7 +135,7 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
                 setFullscreen(false);
             }
         });
-        emulator.bind("rom:loaded", () => {
+        emulator.bind("loaded", () => {
             const romInfo = emulator.getRomInfo();
             setRomInfo(romInfo);
         });
-- 
GitLab