Replies: 2 comments 11 replies
-
This is happening because Also, the more I think about it, the more I think it may not be a good idea to use There may be a way to solve these problems, but it needs work to figure out. |
Beta Was this translation helpful? Give feedback.
-
Although most concerns were addressed in above thread. I found some strange behavior in the below example.
I wouldn't expect that the act of resolving |
Beta Was this translation helpful? Give feedback.
-
In this tweet, pointfreeco have embraced using
@Dependency
in the dependency getter (e.g.liveValue
), although they later discouraged overuse.The example they give uses
.envVars
dependency synchronously to determine whichDatabaseClient
to return.However, I would like to explore the possibily to use dependencies in other dependencies "later", inside their own behavior (think a
.database
dependency's.readTable
endpoint uses.logger
dependency to log the fetched data).Below example summarizes current behavior. This is expected with the current implementation, but the notable part is how "a new
.foo
isn't available to.bar
until after the changes are finished and after the.bar
is reset to a new.liveValue
in a nestedwithDependencies
context.The code is available in this gist.
Not only does the need for nested
withDependencies
calls affect ergonomics, but the required$0.bar = .liveValue
reset overwrites any other changes that may have been made to other endpoints ofBar
. With that, it seems like the pattern of using dependencies in other dependencies is currently not supported and should be discouraged. I have some ideas for potentially improving support for this pattern, but at this point Im unsure if thats even desirable, so I wonder what others have to say on the topic. Thanks in advance.Beta Was this translation helpful? Give feedback.
All reactions