Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry registers bar modules. It can be used to easily register modules until an error is encountered and pass them to `barista.Run`. Modules from registry appear in the bar in the same order as they were added.
registry := modules.NewRegistry() registry. Add(someModule, someOtherModule). Addf(func() (bar.Module, error) { return someModuleFromFactory, nil }) if err := registry.Err(); err != nil { panic(err) } panic(barista.Run(registry.Modules()...))
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new *Registry for bar modules.
func (*Registry) Add ¶
Add adds modules to the registry. Modules that are nil are ignored. If a factory func passed to `Addf` previously returned an error, adding modules here is a no-op.
func (*Registry) Addf ¶
Addf adds a module using a factory func. If the factory returns a nil module, it is ignored. Errors returned by the factory will cause the registry to not accept any more modules via `Add` or `Addf`.