tg/go.go

34 lines
531 B
Go
Raw Normal View History

package tg
func Go(pth Widget) UI {
return UI{
WidgetGo{
Path: pth,
},
}
}
// The type implements changing current path to the widget.
type WidgetGo struct {
Path Widget
Arg any
}
2024-07-23 15:41:31 +03:00
func (w WidgetGo) Act(c Context) {
c.WithArg(w.Arg).Go(w.Path)
}
// Implementing the Server interface.
func (widget WidgetGo) Serve(c Context) {
c.input.Close()
c.WithArg(widget.Path).Go(widget.Path)
}
func (widget WidgetGo) Render(c Context) UI {
return UI{widget}
}
func (widget WidgetGo) Filter(u Update) bool {
return true
}