blasphem/pkg/blas/components.go

22 lines
408 B
Go
Raw Normal View History

2022-12-20 13:31:31 -05:00
package blas
import (
"fmt"
2022-12-20 16:26:04 -05:00
"dynatron.me/x/blasphem/pkg/blas/core"
"dynatron.me/x/blasphem/pkg/components"
2022-12-20 13:31:31 -05:00
)
2022-12-20 19:05:45 -05:00
type Setup func(core.Blas) (components.Component, error)
2022-12-20 16:26:04 -05:00
var Registry = make(map[components.ComponentKey]Setup)
2022-12-20 13:31:31 -05:00
2022-12-20 16:26:04 -05:00
func Register(key components.ComponentKey, c Setup) {
2022-12-20 13:31:31 -05:00
_, already := Registry[key]
if already {
panic(fmt.Sprintf("component %s already exists", key))
}
Registry[key] = c
}