Initialisation of store @main #410
-
What's the preferred way to declare the store at the root level of the SwiftUI app -> @main struct? As this is the entry point the app communicates with, I no longer could rely on dependency injection, thus I statically initialized the store, that is declared as the private member of the app. @main
struct ScrumdingerApp: App {
...
private let store: Store<AppState, AppAction> = {
return Store(initialState: AppState(scrumsState: ScrumsViewState()),
reducer: reducer,
environment: appEnvironment)
}()
...
} My current implementation can be seen here. Is this the right way to do so, though? Thanks! Best, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is where we'd do it, for sure! Our demo apps are written to support iOS 13, so they don't demonstrate this, but we'll probably upgrade them sometime soon, and definitely by the next version of iOS.
Can you clarify what you mean by testability here and what kind of testability you would have outside TCA? Generally TCA testing is done via unit tests and the |
Beta Was this translation helpful? Give feedback.
This is where we'd do it, for sure! Our demo apps are written to support iOS 13, so they don't demonstrate this, but we'll probably upgrade them sometime soon, and definitely by the next version of iOS.
Can you clarify what you mean by testability here and what kind of testability you would have outside TCA? Generally TCA testing is done via unit tests and the
TestStore
class, or snapshot tests will most likely focus more on a feature'sView
and not an application's entireApp
. I'm not aware of any guidance from Apple for testingApp
s.