Using StoreOf<ReducerProtocol>
in @Dependency(\.coreDependency.store) var store
#1880
-
QuestionIs it ok to use Using in my
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Passing stores in dependencies is not something both types were designed for, and I'm almost certain that it will subtlety break things somewhere, and I wouldn't advice to do so. Furthermore, The fact that that you don't have a store at hand to scope from the parent view is a little suspicious, and I don't know if you're not fighting the architecture, if you're in the process of converting a vanilla app to TCA, or if you're in a totally legit situation. As an alternative, and if your domain calls for reusability, you can maybe pass the @EnvironmentObject var viewStore: ViewStore<PaymentState, PaymentAction>
init() {}
var body: some View { … } You would need to extract and inject a |
Beta Was this translation helpful? Give feedback.
Passing stores in dependencies is not something both types were designed for, and I'm almost certain that it will subtlety break things somewhere, and I wouldn't advice to do so. Furthermore,
Dependency
is not built to work inView
, and this is another source of issues that are hard to debug. The "proper" property wrapper to use inView
for a similar function would be@Environment
. If you insist in going the "store from environment/dependencies" route, you can create anEnvironmentKey
to pass your root store in SwiftUI'sEnvironment
. You can then pop this store out from the parent view, and scope it to pass a fully fledged store to yourView
'sinit
like it is commonly done. This should li…