Enhancements for swift-dependencies documentation #2554
evilhonda3030
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
@evilhonda3030 Composable Architecture reducers and stores come with tools that integrate with swift-dependencies, so you should be using them instead of calling to Instead of this: let rootStore = Store(
initialState: ParentFeature.State(value: 99, child: 99),
reducer: {
withDependencies {
$0.dummyDependency.value = { 10 }
} operation: {
ParentFeature()
}
}
) Try this: let rootStore = Store(
initialState: ParentFeature.State(value: 99, child: 99)
) {
ParentFeature()
} withDependencies: {
$0.dummyDependency.value = { 10 }
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I recently discovered some advanced topics about swift-dependencies library in its documentation. There was a lot of information about how we can override dependencies for the certain places in our codebase which was followed by dos and donts examples. Especially there were some examples on how we can propagate overriden dependencies deeper to child features.
However, I see that documentation could have one more on dependencies propagation when it comes to using this library in a TCA environment. Basically this example is about how not to make mistakes when working with an implementation of the
Reducer
protocol.It comes down to not forgetting do this when fulfilling
body
property:Instead of this:
I see this example extremely useful as it clearly shows which pitfalls need to be avoided if we want to get the most out of swift-dependencies right away. Without this example there is a vague which makes you think that probably TCA handles this somehow for you and dependencies will be propagated normally even if
ChildReducer
is initialised directly inbody
. Hence, some developers need to double check constructing some test projects and exploring how it actually works. All in all, I see that this one can potentially save someone's time and be a nice addition to the existing documentation.Here is the link to the gist where the full example can be found: https://gist.github.com/evilhonda3030/2b2ced7ad8373df4e47a0b1b73f6b11d.js
Cheers and appreciate your hard work on making our tech stack better!
Beta Was this translation helpful? Give feedback.
All reactions