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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[feat] add Unused #103

wants to merge 2 commits into from

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

flows.go Show resolved Hide resolved
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"

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