ouichat/plugins/manager.go
2020-05-13 21:52:06 -05:00

23 lines
528 B
Go

package plugins
import "ouichat/core"
// PluginManager is a convenience type that handles everything related to plugins
type PluginManager struct {
root *core.BufferNode
plugins []Plugin
}
func NewPluginManager(root *core.BufferNode) *PluginManager {
return &PluginManager{
root: root,
plugins: make([]Plugin, 0),
}
}
func (man *PluginManager) Spawn(plugin Plugin) {
node := core.NewBufferNode(plugin.Name())
man.root.AddChild(node)
plugin.Init(man, node)
man.plugins = append(man.plugins, plugin)
}