Skip to content

Provide an array of interfaces as a dependency #880

Answered by abhinav
NicklasWallgren asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there! It looks like what you're looking for is value groups.

Value groups are a feature of Fx that allow:

  • producers to produce singular values to a named group
  • consumers to consume all instances of those values produces from all producers in a single slice

You can use value groups in one of two forms:

Value groups with fx.In and fx.Out

To produce values to a value group, make the constructor for your producer return a struct that embeds fx.Out, and annotate the field for the value with group:"name" where "name" is the name of your value group.

type Result struct {
  fx.Out

  Result HealthChecker `gro…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@NicklasWallgren
Comment options

@NicklasWallgren
Comment options

@NicklasWallgren
Comment options

Answer selected by abhinav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants