-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.go
More file actions
33 lines (28 loc) · 1.04 KB
/
component.go
File metadata and controls
33 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package slice
import "github.com/goava/di"
// ComponentOption modifies application components.
type ComponentOption interface {
apply(s *Application)
}
// Provide returns container option that provides to container reliable way to build type. The constructor will
// be invoked lazily on-demand. For more information about constructors see di.Constructor interface. di.ProvideOption can
// add additional behavior to the process of type resolving.
func Provide(constructor di.Constructor, options ...di.ProvideOption) ComponentOption {
return option(func(s *Application) {
s.providers = append(s.providers, di.Provide(constructor, options...))
})
}
// Supply provides value as is.
func Supply(value di.Value, options ...di.ProvideOption) ComponentOption {
return option(func(s *Application) {
s.providers = append(s.providers, di.ProvideValue(value, options...))
})
}
// Group groups component options.
func Group(options ...ComponentOption) ComponentOption {
return option(func(s *Application) {
for _, o := range options {
o.apply(s)
}
})
}