Skip to content
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

[feat] add Unused #103

Merged
merged 3 commits into from
Feb 7, 2025
Merged

[feat] add Unused #103

merged 3 commits into from
Feb 7, 2025

Conversation

muir
Copy link
Owner

@muir muir commented Jan 30, 2025

Add Unused, a provider that will never be included in an injection chain.

Copy link
Collaborator

@dncohen dncohen left a comment

Choose a reason for hiding this comment

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

IMHO it would be even better if the function returned a type Unused. That is, explicitly in the function signature it will never be part of the chain.

I think returning Provider invites someone to write a function that conditionally returns Unused in some case, and some other provider in others. Which I expect would become hard logic to follow.

Take or leave that suggestion, I'm approving as is.

@muir
Copy link
Owner Author

muir commented Jan 30, 2025

Hmm. Both are useful. Making a type Unused is more work. I can see how it is more documenting though. The question is: what should the behavior be if someone wants to have Unused as an input?

I guess the most robust answer is that Unused is not preserved: as an input, it's magically supplied even if there is no provider and as an output, the value is not preserved.

@dncohen
Copy link
Collaborator

dncohen commented Jan 30, 2025

Hmm. Both are useful. Making a type Unused is more work. I can see how it is more documenting though. The question is: what should the behavior be if someone wants to have Unused as an input?

An error? I think better to fail than silently do something unexpected. Users will assume rather than understand (I say this as a user).

bind.go Outdated
Comment on lines 87 to 90
funcs = append(funcs, nil)
for i := len(funcs) - 1; i > 0; i-- {
funcs[i] = funcs[i-1]
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

as discussed, helper to "append to front" and "append near end"

@muir muir merged commit 6c299ab into main Feb 7, 2025
17 checks passed
@muir muir deleted the addUnused branch February 7, 2025 23:29
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