Skip to content

Commit

Permalink
docs: container
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrukowski committed Oct 31, 2023
1 parent 3d4998a commit 04312a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ var (
/*
New creates a concurrent-safe DI Container.
type God struct {
type Person struct {
Name string
}
s := container.NewService()
s.SetConstructor(
func(n string) God {
return God{
func(n string) Person {
return Person{
Name: n,
}
},
Expand Down
14 changes: 7 additions & 7 deletions container/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func (s *Service) SetConstructor(fn any, deps ...Dependency) *Service {
AppendCall instructs the container to execute a method over that object.
s := container.NewService()
s.SetConstructor(func() *God {
return &God{}
s.SetConstructor(func() *Person {
return &Person{}
})
s.AppendMethod("SetName", container.NewDependencyValue("Jane"))
// p := &God{}
// p := &Person{}
// p.SetName("Jane")
*/
func (s *Service) AppendCall(method string, deps ...Dependency) *Service {
Expand All @@ -115,10 +115,10 @@ func (s *Service) AppendCall(method string, deps ...Dependency) *Service {
AppendWither instructs the container to execute a wither-method over that object.
s := container.NewService()
s.SetValue(God{})
s.SetValue(Person{})
s.AppendWither("WithName", container.NewDependencyValue("Jane"))
// p := God{}
// p := Person{}
// p = p.WithName("Jane")
*/
func (s *Service) AppendWither(method string, deps ...Dependency) *Service {
Expand All @@ -134,10 +134,10 @@ func (s *Service) AppendWither(method string, deps ...Dependency) *Service {
SetField instructs the container to set a value of the given field.
s := container.NewService()
s.SetValue(God{})
s.SetValue(Person{})
s.SetField("Name", container.NewDependencyValue("Jane"))
// p := God{}
// p := Person{}
// p.Name = "Jane"
*/
func (s *Service) SetField(field string, dep Dependency) *Service {
Expand Down

0 comments on commit 04312a5

Please sign in to comment.