Replies: 1 comment 4 replies
-
I'm not familiar with the library that offers We would not recommend using anything but a value type for reducers, for a similar reason that you wouldn't conform a class to be a SwiftUI view: reducers are very lightweight descriptions of behavior, and we expect them to be initialized basically every single time an action comes into the system. Because of this, mutating a class will not behave as you might expect: the class would immediately be reinitialized after it processed the action, and the write would not be visible. Now this may not matter for your dependency injection library if it writes to some global store, like ours does, but if that is the case, then it's possible that you should be able to use such a property wrapper with a struct anyway, but the setter needs to be marked as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a Feature (I'm calling it a feature because of some additional requirements over the plain ReducerProtocol):
So as you can see, I'm using another dependency injection library that lets me inject my dependencies lazily, but lazily mutating a property requires some more extra directives on the struct and its functions.
So one option is to change the
struct
to aclass
. A side effect example of this change is when I need to perform aTaskResult
, it forces to capture theself
:Is it ok to pass the feature around as a reference? What happens if I capture the feature? What happens to the cancelation?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions