Skip to content

Why does order of fx.Invoke affect soft value group results? #1028

Answered by sywhang
sywhang asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't "by design" of soft value groups, but rather a limitation in Fx introduced by Invoke.

The order of Invokes change whether the constructors that provide the soft value group has already run or not. In your example, the "hard" running before soft will populate the soft value group dependency because the constructor that provides the soft value is forced to run.

This is one of the main reasons we recommend that Invokes be used sparingly.

Be deliberate in your choice to use fx.Invoke in your module. By design, Fx executes constructors added via fx.Provide only if the application consumes its result, either directly or indirectly, through another module, constructor, or invoke. On …

Replies: 1 comment

Comment options

sywhang
Jan 17, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by sywhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant