-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply to struct without connect #5
base: master
Are you sure you want to change the base?
Conversation
} else if (sf.Type.Kind() == reflect.Ptr || sf.Type.Kind() == reflect.Interface) && rv.Field(i).IsNil() { | ||
panic(tagMissingError{field: sf}) | ||
// Is this required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to use an external library where wire:"-"
can't be added, so is more of a question :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for validation purpose, to ensure all dependency is properly added and connected.
Hmm, I never consider the case where external library might have nil pointer or interface.
How if we add another variant of Connect
function that allows bypassing this check?
} else if (sf.Type.Kind() == reflect.Ptr || sf.Type.Kind() == reflect.Interface) && rv.Field(i).IsNil() { | ||
panic(tagMissingError{field: sf}) | ||
// Is this required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for validation purpose, to ensure all dependency is properly added and connected.
Hmm, I never consider the case where external library might have nil pointer or interface.
How if we add another variant of Connect
function that allows bypassing this check?
container.components[rt] = append(container.components[rt], comp) | ||
return | ||
} | ||
dependinces := make([]dependency, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this supposed to be dependencies
?
https://www.collinsdictionary.com/dictionary/english/dependencies
@@ -183,7 +206,37 @@ func (container Container) Resolve(out interface{}, id ...string) { | |||
} | |||
|
|||
// Apply wiring to all components. | |||
func (container Container) Apply() { | |||
func (container Container) Apply(to ...interface{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, this allows components added directly in apply function right?
|
||
container.fill(comp) | ||
|
||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to return here? this will cause other components that connected using Connect
to be not added right?
No description provided.