You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning "An "observe" was called from another "observe" closure, which can lead to over-observation and unintended side effects." was added in version 1.9.3 and become at unnecessary cases
I attach example project where you can see that bug BadObserveExample.zip
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.
@nmalevich We recently added this runtime warning because nested observes can have unintended consequences. In this case, a viewDidLoad is evaluated in the same stack as the presenting view controller's observe, which means all child state evaluated in the child controller's observe will be observed by the parent.
To work around the problem, you can move observe into viewWillAppear instead, and manage the lifetime of the observation token, or you can dispatch the observation a tick in viewDidLoad:
DispatchQueue.main.async {
observe { [weak self] in
…
}
}
We're still deciding if this warning is too heavy-handed, but we don't consider it a bug at the moment. Because of this I'm going to convert this to a discussion.
Description
Warning "An "observe" was called from another "observe" closure, which can lead to over-observation and unintended side effects." was added in version 1.9.3 and become at unnecessary cases
I attach example project where you can see that bug
BadObserveExample.zip
Checklist
main
branch of this package.Expected behavior
Warning doesn't appear
Actual behavior
Warning appears
Steps to reproduce
Just run app and wait. Screens will navigate by themselves
The Composable Architecture version information
1.9.3
Destination operating system
iOS 17.4.1
Xcode version information
15.3
Swift Compiler version information
The text was updated successfully, but these errors were encountered: