pointfreeco/swift-composable-architecture

Dismissing more than one feature

nmalevich opened this issue · 1 comments

Description

When I have migrated to 1.9 version from 1.3 and started to use @ObservableState, @presents, observe {}(I use UIKit for UI) and all what you recommend. All is good and thank you for your effort to improve TCA.

But now I have one problem with dismiss dependency. I didn't have this problem when I used 1.3 version. The problem is when I execute dismiss() from dismiss dependency at my child feature, not only my child feature set nil, but the parent feature too. The parent feature is added to main reducer by Scope(state:action:) and child feature by .ifLet(state: .$destination, action: .destination)

Yes, I have tried to use just callback effects from child features, detect them in parent reducer and set destination nil and it works well. But I want to use more simple way and exactly want to understand why this bug reproduce

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

After dismiss() set nil for only one(child) feature

Actual behavior

After dismiss() set nil for two(parent and child) features

Steps to reproduce

I can't share all my project, because it's not mine and I don't have this opportunity, but I can share with you some logs and results

I will share with you two variants of my app. And this variants have only one difference

  1. With bug. I have this sending line on View that is connected with child feature
Снимок экрана 2024-03-06 в 16 41 14
  1. No bug. I commented this sending line
Снимок экрана 2024-03-06 в 16 42 11

This action "test" isn't detected on any reducers, so it can't influence for something

test1.txt
Снимок экрана 2024-03-06 в 16 48 07
Снимок экрана 2024-03-06 в 16 48 18

test2.txt

You can also pay your attention to logs like this "<decode: bad range for [%@] got [offs:346 len:932 within:0]>". I'm sure that this error log is connected with the problem

The Composable Architecture version information

1.9.0

Destination operating system

iOS 17.3

Xcode version information

15.2

Swift Compiler version information

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: x86_64-apple-macosx14.0

Hi @nmalevich, can you please provide a project that demonstrates the behavior you are seeing? I don't think this is an issue with the library so I am going to convert this to a discussion for now. We can re-open an issue if it turns out to be something wrong with TCA.