Add support for rendering Blazor components on applying a hot reload delta (original) (raw)
- Assume some mechanism exists that notifies the framework when a delta is applied.
- We introduce a new contract that is implemented by
ComponentBase. This allows components to subscribe to events that make them aware that a rendering is being triggered as a response to delta apply event:
IHotReloadableComponent { void UseHotReloadableContext(HotReloadableContext context); }
class HotReloadableContext { bool IsHotReloading(); }
- ComponentBase.ShouldRender() is ignored when
Context.IsHotReloading()returns true. - RenderRootComponentAsync stashes away root component parameters when we know hot reload is enabled for the app (look for the environment variable) and uses this to trigger a render when delta is applied.