diff --git a/tg/reply.go b/tg/reply.go index 60aca27..80884f0 100644 --- a/tg/reply.go +++ b/tg/reply.go @@ -141,7 +141,4 @@ func (widget *ReplyWidget) Serve(c *Context) { } } -type DynamicReplyWidget struct { - -} diff --git a/tg/widget.go b/tg/widget.go index 7d5923a..10227d8 100644 --- a/tg/widget.go +++ b/tg/widget.go @@ -5,6 +5,15 @@ import ( //"fmt" ) +type Maker[V any] interface { + Make(*Context) V +} + +type MakeFunc[V any] func(*Context) V +func (fn MakeFunc[V]) Make(c *Context) V { + return fn(c) +} + type ArgMap = map[string] any type ArgSlice = []any type ArgList[V any] []V @@ -20,6 +29,10 @@ type Widget interface { Serve(*Context) } +type DynamicWidget[W Widget] interface { + Maker[W] +} + // Implementing the interface provides ability to // be used as the root widget for contexts. type RootWidget interface {