Comments (2)
I'm noticing that the
ifLet
call on the store is called multiple times.
Do you mean that the then:
closure is being called multiple times, causing your view controller to be presented multiple times?
When each modal is dismissed are you making sure, in your reducer, that the state for the modal (eg items
or favourites
) is reset to nil
?
The "fix" is to use skipRepeats() instead of .skipRepeats { ($0 != nil) == ($1 != nil) }.
The { ($0 != nil) == ($1 != nil) }
comparison test (instead of using the default ==
) is to test for changes from nil to non-nil and vice-versa, which is what is needed for ifLet
, otherwise any change in the state whilst it's non-nil would also cause the then:
closure to be called, which is not what we want.
FWIW I'm using ifLet
in my work project and have not run into the problem that you describe.
from reactiveswift-composable-architecture.
Thanks for the response! I think I found my issue. I was doing store.ifLet
within viewStore.produced.activeRoute.startWithValues
. I didn't realize that store.ifLet
was creating new subscriptions to the store each time.
viewStore.produced.activeRoute.startWithValues { [weak self] route in
switch route {
...
case .favorites:
let store = self.store.scope(state: \.favorites, action: Root.Action.favorites)
store.ifLet { [weak self] store in
guard let self = self else { return }
let vc = FavoritesViewController(store: store)
let nc = UINavigationController(rootViewController: vc)
nc.presentationController?.delegate = self
self.present(nc, animated: true, completion: nil)
}
}
}
So every time I got a new route
I was attempting to unwrap the optional store, not realizing that the previously unwrapped store subscription was still hanging around. So the previous ifLet
block was still getting called.
I think the wording on ifLet
makes it seem as if you are doing an in-place unwrap once, but in reality you are creating a new subscription to an observable. I know the wording is inherited from the Point-Free repo, so I guess I can bring that concern up there. I'll close this issue. Thanks again!
from reactiveswift-composable-architecture.
Related Issues (8)
- Nested properties keyPath support for Produced values HOT 6
- ViewStore version without Combine/SwiftUI HOT 16
- Change TestStore so that it isn't only compiled when running in DEBUG HOT 4
- Is there any plans on releasing this framework to CocoaPods? HOT 10
- Please make Effect.throttle public HOT 12
- Object get deallocated on Signal.Observer HOT 3
- Include TCA Swift Concurrency changes from release 0.39.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveswift-composable-architecture.