Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
I have been looking for a manner to trigger a hot reload in my browser after a service reloads some JSON files.
I don't want the watcher to consider my changes to the JSON files as rude edits, so I'm not adding them to the list of watched files. I have already provided a mechanism for developers to reload the files via a PhysicalFileProvider, copying the files from the source path to the debug build path, and reloading them in memory when a debugger is attached or the environment variables for DOTNET_WATCH is 1. But I have found no way to let the browser know that it should refresh. I have tried sending empty updates via MetadataUpdater.ApplyUpdate
as a hackish way to trigger a notification, but that (expectedly) failed.
I think it would help tremendously the DX, especially for those of us working on new libraries.
Describe the solution you'd like
A simple class injected (or not) that gives you a a watcher context, fulfilling this contract:
interface IWatcherContext
{
bool HasWatcher { get; } // Is the application running through dotnet watch?
bool IsHotReloadEnabled { get; } // Is the hot reload option enabled
bool IsBrowserRefreshEnabled { get; } // Is browser refresh option enabled
void NotifyBrowser(); // Notifies the browser that it needs to refresh.
// ...
}
Additional context
No response