-
Hi all, Have a very basic question for the community and hoping someone can shed light on the same. In the two counters SwiftUI case study linked here, is it expected that the Counter reducer will be initialized everytime the counter state changes? Intuitively it makes sense that whenever an action needs to be executed on some state that a reducer needs to be created to modify that state but in a situation where there are a lot of rapid UI updates occurring, such as say when a video is being played and its state is being tracked or an animation is occurring and similarly its state is being tracked, it feels wasteful to be creating the reducer repeatedly. Or is this just not a performance issue to be worried about at all? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @nrkrishna, this situation is no different from how SwiftUI works with structs conforming to the You should not think of the struct representation of your feature's reducer as representing the feature's lifecycle. Instead the real life cycle is handled by modeling the presentation and dismissal of features as optional/enum state, and then using the navigation tools that come with the library. |
Beta Was this translation helpful? Give feedback.
Hi @nrkrishna, this situation is no different from how SwiftUI works with structs conforming to the
View
protocol. The struct representation of views are created thousands of times while your app is running. It is not a problem to do so.You should not think of the struct representation of your feature's reducer as representing the feature's lifecycle. Instead the real life cycle is handled by modeling the presentation and dismissal of features as optional/enum state, and then using the navigation tools that come with the library.