Skip to content

Conversation

@albulescu
Copy link

No description provided.


} else if (sf.Type.Kind() == reflect.Ptr || sf.Type.Kind() == reflect.Interface) && rv.Field(i).IsNil() {
panic(tagMissingError{field: sf})
// Is this required
Copy link
Author

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 :)

Copy link
Owner

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
Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Apply wiring to all components.
func (container Container) Apply() {
func (container Container) Apply(to ...interface{}) {
Copy link
Owner

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
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants