-
Hi, I was struggling for a few hours today on a bug in my app and now that I've fixed it, I would like to understand better why it was occurring. TL;DR: a missing Basically, I have a feature which wraps another feature in an enum. A very simplified version looks like: @ObservableState
struct State: Equatable {
var wrapped: Wrapped
@dynamicMemberLookup
@CasePathable
enum Wrapped: Equatable {
case inner(Refreshable.State)
}
} Most of the functionality of the inner feature is not important, but I did implement a pull-to-refresh behavior, as demonstrated in the case studies. Unfortunately, when I added the The reducer for ⭐ The fix was to add the missing
let outer = store.scope(state: \.wrapped, action: \.wrapped)
let inner = outer.scope(state: \.inner, action: \.self)
// this doesn’t work, the optional is still on the store state type
RefreshableView(store: inner)
// this works, since the top-level State is ObservableState, but we have no guarantees about intermediate states
if let scoped = store.scope(state: \.wrapped.inner, action: \.wrapped) {
RefreshableView(store: scoped)
} I tried to create a minimal example of this error to more thoroughly understand the problem, but was unable to reproduce the problem in a wrapper around the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @zgotsch, I can only guess at many of these questions without a project to look at. I know you tried to create one already, but having that would turn these guesses into more concrete answers.
My guess is that your effect was cancelled, and therefore it is not allowed to send any more actions into the system. We could warn on this, but I think it would actually be very noisy and not what people actually care about. I think there are a lot of effects out there that don't proactively end their work upon cancellation and may accidentally send an action after being cancelled.
My guess is that the This would also explain why you saw it working when using And now that I think about it, this would also explain why the problem was fixed with adding
I'm not sure I understand the question or the code sample. Can you explain a bit more? |
Beta Was this translation helpful? Give feedback.
Hi @zgotsch, I can only guess at many of these questions without a project to look at. I know you tried to create one already, but having that would turn these guesses into more concrete answers.
My guess is that your effect was cancelled, and therefore it is not allowed to send any more actions into the system. We could warn on this, but I think it would actually be very noisy and not what people actually care about. I think there are a lot of effects out there that don't proactively …