Skip to content

Commit

Permalink
Added App.OnHotReload, which only fires in DEBUG builds
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyThorson committed Feb 22, 2024
1 parent d867089 commit a6d0701
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Framework/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ public static bool MouseVisible
/// </summary>
public static Action? OnExitRequested;

/// <summary>
/// Called only in DEBUG builds when a hot reload occurs.
/// </summary>
public static Action? OnHotReload;

/// <summary>
/// The Main Thread that the Application was Run on
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions Framework/Utility/HotReloadHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#if DEBUG

[assembly: System.Reflection.Metadata.MetadataUpdateHandler(typeof(Foster.Framework.HotReloadHandler))]

namespace Foster.Framework;

internal static class HotReloadHandler
{
public static void UpdateApplication(Type[]? _)
=> App.OnHotReload?.Invoke();
}

#endif

0 comments on commit a6d0701

Please sign in to comment.