Any way to use @ObservableState
with @Dependency
properties?
#388
-
Hello all. Was wondering if there's any way of using the following:
currently, because the ObservableState macro is generating code for the would be really beneficial if this could be achieved somehow, or any other ideas are welcomed, as in the project i'm working we have quite the number of use cases where we use @dependency objects inside States to compute a bunch of stuff. ie we use @dependency(.date), @dependency(.calendar), etc PS adding the implementation of
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @danielavrammindera, you just have to use However, I'm not sure it is a good idea to use |
Beta Was this translation helpful? Give feedback.
-
closing this as @mbrandonw pretty much answered the question. if there are any other suggestions for my follow up question, please feel free to answer, but as the actual question has been answered, this can be closed |
Beta Was this translation helpful? Give feedback.
Hi @danielavrammindera, you just have to use
@ObsevationStateIgnored
on the property, just as you would with@Observable
.However, I'm not sure it is a good idea to use
@Dependency
in your state because that means the state can't beEquatable
and so you can't write tests for the feature. Further, any access of a@Dependency
outside of the reducer will not pick up any dependency overrides that are made using the.dependency
reducer modifier.