Documentation
¶
Overview ¶
Package flight implements a stack-based navigation system for Kitex applications.
By favoring a type-safe stack navigator (push/pop) over URL-based path routing, flight provides a paradigm that matches TUI (Terminal User Interface) design patterns and enforces strict keyboard focus containment to the active screen.
# Type-Safe Routes Routes are represented as empty interfaces (flight.Route). Concrete routes are defined using user-defined structs which hold type-safe parameters:
type HomeRoute struct{}
type DetailsRoute struct {
ItemID string
}
# Rendering and Type Switches The Stack component renders the active route by dispatching it to a developer-provided RenderRoute function, which uses a Go type switch to instantiate the corresponding component:
flight.Stack(flight.StackProps{
InitialRoute: HomeRoute{},
RenderRoute: func(r flight.Route) kitex.Node {
switch route := r.(type) {
case HomeRoute:
return HomeView()
case DetailsRoute:
return DetailsView(route.ItemID)
default:
panic("unknown route")
}
},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Stack ¶
func Stack(props StackProps) kitex.Node
Stack is a reactive navigation component that maintains a stack of active routes. It wraps the active route with NavigatorContext provider and dynamically isolates keyboard interaction to the top-most view using the active route's DOM node.
Types ¶
type Navigator ¶
type Navigator interface {
Push(r Route)
Pop()
PopToTop()
CanPop() bool
Current() Route
Depth() int
Replace(r Route)
Reset(r Route)
}
Navigator defines the operations to manipulate and inspect the navigation history stack.
func UseNavigation ¶
func UseNavigation() Navigator
UseNavigation retrieves the current Navigator instance from the kitex context. It panics if called outside of a flight.Stack component.