Documentation
¶
Index ¶
- Variables
- func Make[T any](c *Container) (T, error)
- type Container
- func (c *Container) AfterHook(fn func())
- func (c *Container) Alias(alias string, iface any) error
- func (c *Container) Bind(iface any, factory any) error
- func (c *Container) Call(fn any) ([]any, error)
- func (c *Container) Flush()
- func (c *Container) Freeze()
- func (c *Container) Has(iface any) bool
- func (c *Container) Instance(iface any, instance any) error
- func (c *Container) MakeAlias(alias string) (any, error)
- func (c *Container) Resolve(typ reflect.Type) (any, error)
- func (c *Container) Singleton(iface any, factory any) error
- func (c *Container) Tagged(iface any, tag string, factory any) error
- func (c *Container) TaggedOf(tag string) ([]any, error)
- func (c *Container) Unbind(iface any)
- func (c *Container) When(concrete any) *ContextualBindingBuilder
- type ContextualBindingBuilder
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is the IoC container.
func (*Container) AfterHook ¶
func (c *Container) AfterHook(fn func())
AfterHook registers a callback to run after the container is frozen.
func (*Container) Flush ¶
func (c *Container) Flush()
Flush removes all bindings and instances from the container.
func (*Container) Freeze ¶
func (c *Container) Freeze()
Freeze locks the container from further mutations.
func (*Container) When ¶
func (c *Container) When(concrete any) *ContextualBindingBuilder
When begins defining a contextual binding.
type ContextualBindingBuilder ¶
type ContextualBindingBuilder struct {
// contains filtered or unexported fields
}
ContextualBindingBuilder helps build a contextual binding.
func (*ContextualBindingBuilder) Give ¶
func (b *ContextualBindingBuilder) Give(factory any)
Give specifies the factory to provide when the context is resolved.
func (*ContextualBindingBuilder) Needs ¶
func (b *ContextualBindingBuilder) Needs(iface any) *ContextualBindingBuilder
Needs specifies the interface needed by the concrete class.
Click to show internal directories.
Click to hide internal directories.