Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
// Render generates the virtual DOM tree for this component.
// The renderer parameter provides access to framework services like RenderChild.
Render(r Renderer) *vdom.VNode
// SetRenderer is called by the framework to attach the renderer to the component.
// This enables StateHasChanged() to trigger re-renders.
SetRenderer(r Renderer)
}
Component interface defines the structure for all components in the framework. This interface has NO build tags, making it available to both WASM and native test builds. The Render method accepts the Renderer interface (not concrete type) so both WASM and test implementations can use it.
type ComponentBase ¶
type ComponentBase struct {
// contains filtered or unexported fields
}
ComponentBase is a struct that components can embed to gain access to the StateHasChanged method, which triggers a UI re-render. This type has no build tags and works in both WASM and test environments.
func (*ComponentBase) GetRenderer ¶
func (b *ComponentBase) GetRenderer() Renderer
GetRenderer returns the renderer instance associated with this component. Used internally by components that need direct access to renderer methods.
func (*ComponentBase) Navigate ¶
func (b *ComponentBase) Navigate(path string) error
Navigate requests client-side navigation to a new path. This is used by components (such as Link) to trigger routing without full page reloads. The path will be passed to the router, which will update the browser URL and render the appropriate component.
Example usage in a component:
func (c *MyComponent) HandleClick() {
if err := c.Navigate("/about"); err != nil {
println("Navigation failed:", err.Error())
}
}
Returns an error if the renderer is not set or navigation fails.
func (*ComponentBase) SetRenderer ¶
func (b *ComponentBase) SetRenderer(r Renderer)
SetRenderer is called by the framework's runtime to inject a reference to the renderer, enabling StateHasChanged. This method should not be called by user code.
func (*ComponentBase) SetSlotParent ¶
func (b *ComponentBase) SetSlotParent(parent Component)
SetSlotParent associates this component with a parent layout. Called by the renderer when mounting a child into a layout's []*vdom.VNode slot. No DOM attributes are added—the relationship is tracked entirely in Go memory.
func (*ComponentBase) StateHasChanged ¶
func (b *ComponentBase) StateHasChanged()
StateHasChanged signals to the framework that the component's state has been updated and the UI should be re-rendered to reflect the changes. If this component is mounted inside a layout's []*vdom.VNode slot, triggers scoped re-render of only that slot. Otherwise, full re-render.
type Renderer ¶
type Renderer interface {
// RenderChild is used by generated code to render child components.
// The key parameter uniquely identifies the component instance for state preservation.
RenderChild(key string, childWithProps Component) *vdom.VNode
// ReRender requests that the renderer re-run the render cycle.
// Used by StateHasChanged() when component state changes.
ReRender()
// ReRenderSlot patches only the BodyContent slot of a layout,
// preserving the layout instance and its state.
// Called when a page component (inside a layout's slot) calls StateHasChanged().
// It diffs the entire parent layout's VDOM; only changed content is patched.
ReRenderSlot(slotParent Component) error
// Used by Link components and programmatic navigation.
Navigate(path string) error
}
Renderer defines the minimal set of runtime operations used by generated Render() code. This interface has NO build tags, making it available to both WASM and native test builds. This allows the AOT compiler to generate identical Render() signatures for both environments.