-
I am trying to include tca into a document app of mine that has tabs. I guess it has to do with the mentioned binding of the document to the AppFeature, but I am not quite sure as to how I could handle that differently... You can observe the behaviour in this screencast I did on a sample project: Since the sample project has a certain size already, I put it up to GitHub to take a look at–I am aware that looking that up there is quite involved so if anybody could find some any time at all to take a look at it and perhaps have some tips for me, I would highly appreciate it! Here's the repo: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Shoutout to https://github.com/treboc who helped me figuring this out. Instead I am now rather instantiating the store in the Scene entry point of the app: +import ComposableArchitecture
import SwiftUI
@main
struct so_tca_docBasedWithTabsApp: App {
- var body: some Scene {
- DocumentGroup(newDocument: so_tca_docBasedWithTabsDocument()) { file in
- AppView(document: file.$document)
- }
+ var body: some Scene {
+ DocumentGroup(newDocument: so_tca_docBasedWithTabsDocument()) { file in
+ AppView(document: file.$document, store: createStore(with: file.document.text))
}
+ }
+
+ func createStore(with text: String) -> StoreOf<AppFeature> {
+ Store(
+ initialState: AppFeature.State(text: "Hello, world!")) {
+ AppFeature()
+ }
+ }
} |
Beta Was this translation helpful? Give feedback.
-
This compare should show what I did wrong and what I did to fix it (perhaps it is of help to somebody or even my future self...) |
Beta Was this translation helpful? Give feedback.
Shoutout to https://github.com/treboc who helped me figuring this out.
Seems as though what my mistake was is that I was instantiating the store in the init of the AppView which meant that it got re-rendered on every change.
Instead I am now rather instantiating the store in the Scene entry point of the app: