Skip to content

Commit 6b2f62e

Browse files
[Examples] Declare store as static to avoid interference with Xcode previews (#3618)
* Voice Memos update: declare store as static to avoid interference with Xcode previews * Todos update: declare store as static to avoid interference with Xcode previews * SpeechRecognition update: declare store as static to avoid interference with Xcode previews * Search update: declare store as static to avoid interference with Xcode previews * remove: remove @mainactor, if isTesting * [SyncUps] remove @mainactor * Apply suggestions from code review * fix method name --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent 76c4411 commit 6b2f62e

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

Examples/Search/Search/SearchApp.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import SwiftUI
33

44
@main
55
struct SearchApp: App {
6+
static let store = Store(initialState: Search.State()) {
7+
Search()
8+
._printChanges()
9+
}
10+
611
var body: some Scene {
712
WindowGroup {
8-
SearchView(
9-
store: Store(initialState: Search.State()) {
10-
Search()
11-
._printChanges()
12-
}
13-
)
13+
SearchView(store: Self.store)
1414
}
1515
}
1616
}

Examples/SpeechRecognition/SpeechRecognition/SpeechRecognitionApp.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import SwiftUI
33

44
@main
55
struct SpeechRecognitionApp: App {
6+
static let store = Store(initialState: SpeechRecognition.State()) {
7+
SpeechRecognition()
8+
._printChanges()
9+
}
10+
611
var body: some Scene {
712
WindowGroup {
8-
SpeechRecognitionView(
9-
store: Store(initialState: SpeechRecognition.State()) {
10-
SpeechRecognition()._printChanges()
11-
}
12-
)
13+
SpeechRecognitionView(store: Self.store)
1314
}
1415
}
1516
}

Examples/SyncUps/SyncUps/App.swift

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import SwiftUI
55
struct SyncUpsApp: App {
66
// NB: This is static to avoid interference with Xcode previews, which create this entry
77
// point each time they are run.
8-
@MainActor
98
static let store = Store(initialState: AppFeature.State()) {
109
AppFeature()
1110
._printChanges()

Examples/Todos/Todos/TodosApp.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import SwiftUI
33

44
@main
55
struct TodosApp: App {
6+
static let store = Store(initialState: Todos.State()) {
7+
Todos()
8+
._printChanges()
9+
}
10+
611
var body: some Scene {
712
WindowGroup {
8-
AppView(
9-
store: Store(initialState: Todos.State()) {
10-
Todos()
11-
}
12-
)
13+
AppView(store: Self.store)
1314
}
1415
}
1516
}

Examples/VoiceMemos/VoiceMemos/VoiceMemosApp.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import SwiftUI
33

44
@main
55
struct VoiceMemosApp: App {
6+
static let store = Store(initialState: VoiceMemos.State()) {
7+
VoiceMemos()
8+
._printChanges()
9+
}
10+
611
var body: some Scene {
712
WindowGroup {
8-
VoiceMemosView(
9-
store: Store(initialState: VoiceMemos.State()) {
10-
VoiceMemos()._printChanges()
11-
}
12-
)
13+
VoiceMemosView(store: Self.store)
1314
}
1415
}
1516
}

0 commit comments

Comments
 (0)