From 185c8fc1f844a1f6f6028913be9cd6e9480dc7cb Mon Sep 17 00:00:00 2001 From: surdeus Date: Mon, 25 Sep 2023 20:15:57 +0300 Subject: [PATCH] More refactoring. --- tg/reply.go | 3 --- tg/widget.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) 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 {