Browse Source

修复调试发现的问题

pull/1/head
Sydonian 2 years ago
parent
commit
edacd60612
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      pkg/typedispatcher/type_dispatcher.go

+ 6
- 0
pkg/typedispatcher/type_dispatcher.go View File

@@ -12,6 +12,12 @@ type TypeDispatcher[TRet any] struct {
handlers map[reflect.Type]HandlerFn[TRet] handlers map[reflect.Type]HandlerFn[TRet]
} }


func NewTypeDispatcher[TRet any]() TypeDispatcher[TRet] {
return TypeDispatcher[TRet]{
handlers: make(map[reflect.Type]HandlerFn[TRet]),
}
}

func (t *TypeDispatcher[TRet]) Add(typ reflect.Type, fn HandlerFn[TRet]) { func (t *TypeDispatcher[TRet]) Add(typ reflect.Type, fn HandlerFn[TRet]) {
t.handlers[typ] = fn t.handlers[typ] = fn
} }


Loading…
Cancel
Save