Skip to content

Commit

Permalink
remove container option
Browse files Browse the repository at this point in the history
  • Loading branch information
Michelle Laurenti committed Mar 7, 2024
1 parent 6b4ddf6 commit cd7d216
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 257 deletions.
17 changes: 0 additions & 17 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,13 @@ func WithDecoratorCallback(callback Callback) DecorateOption {
}
}

// WithContainerCallback returns an [Option] which has Dig call
// the passed in [Callback] each time a new value
// is constructed.
//
// See [CallbackInfo] for more info on the information passed
// to the [Callback].
func WithContainerCallback(callback Callback) Option {
return withCallbackOption{
callback: callback,
}
}

type withCallbackOption struct {
callback Callback
}

var (
_ ProvideOption = withCallbackOption{}
_ DecorateOption = withCallbackOption{}
_ Option = withCallbackOption{}
)

func (o withCallbackOption) applyProvideOption(po *provideOptions) {
Expand All @@ -124,7 +111,3 @@ func (o withCallbackOption) applyProvideOption(po *provideOptions) {
func (o withCallbackOption) apply(do *decorateOptions) {
do.Callback = o.callback
}

func (o withCallbackOption) applyOption(c *Container) {
c.scope.callback = o.callback
}
8 changes: 0 additions & 8 deletions constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ func (n *constructorNode) Call(c containerStore) (err error) {

values = n.resultList.Values(results)

if n.s.callback != nil {
n.s.callback(CallbackInfo{
Name: fmt.Sprintf("%v.%v", n.location.Package, n.location.Name),
Error: err,
Values: values,
})
}

n.called = true
return nil
}
Expand Down
8 changes: 0 additions & 8 deletions decorate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ func (n *decoratorNode) Call(s containerStore) (err error) {
}
values = n.results.Values(results)

if n.s.callback != nil {
n.s.callback(CallbackInfo{
Name: fmt.Sprintf("%v.%v", n.location.Package, n.location.Name),
Error: err,
Values: values,
})
}

n.state = decoratorCalled
return nil
}
Expand Down
Loading

0 comments on commit cd7d216

Please sign in to comment.