TermUI.Dev.HotReload (TermUI v0.2.0)
View SourceHot Reload integration for development mode.
Watches .ex files for changes and reloads modules without restarting the application. State is preserved across reloads where possible.
Usage
# Start hot reload
HotReload.start()
# Stop hot reload
HotReload.stop()
# Manually reload a module
HotReload.reload_module(MyModule)How It Works
- File watcher monitors lib/ directory for .ex changes
- On change, affected modules are identified
- Modules are recompiled using Mix
- Old code is purged and new code loaded
- Notification sent to UI
Note: Uses polling-based approach for compatibility.
Summary
Functions
Checks if a module can be hot reloaded.
Returns a specification to start this module under a supervisor.
Gets the source file path for a module.
Gets recently reloaded modules.
Sets callback for reload notifications.
Manually reloads a specific module.
Returns whether hot reload is running.
Starts watching for file changes.
Starts the hot reload watcher.
Stops watching for file changes.
Types
Functions
Checks if a module can be hot reloaded.
Some modules (like those with NIFs or ports) may not reload properly.
Returns a specification to start this module under a supervisor.
See Supervisor.
Gets the source file path for a module.
@spec get_recent_reloads() :: [{module(), DateTime.t()}]
Gets recently reloaded modules.
Sets callback for reload notifications.
Manually reloads a specific module.
@spec running?() :: boolean()
Returns whether hot reload is running.
@spec start() :: :ok
Starts watching for file changes.
Starts the hot reload watcher.
@spec stop() :: :ok
Stops watching for file changes.