Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Revert to a direct store binding for AppTab (#1137)
Browse files Browse the repository at this point in the history
Fixes #1138

After landing
#1132 it appears
that this layer of indirection is no longer making a significant
difference to performance... which is good!
  • Loading branch information
bfollington authored Mar 19, 2024
1 parent 8313cc3 commit fd715b7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions xcode/Subconscious/Shared/Components/AppTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ enum AppTab: String, Hashable {

struct AppTabView: View {
@ObservedObject var store: Store<AppModel>
// For performance purposes we proxy this state through to the store
// in the background. This is a stop-gap solution until we find a
// general approach to fine-grained reactivity.
@State var selectedTab: AppTab = .notebook

var body: some View {
TabView(selection: $selectedTab) {
TabView(
selection: store.binding(
get: \.selectedAppTab,
tag: AppAction.setSelectedAppTab
)
) {
DeckView(app: store)
.tabItem {
Label("Deck", systemImage: "square.stack.3d.up.fill")
Expand All @@ -49,11 +50,5 @@ struct AppTabView: View {
}
.tag(AppTab.profile)
}
.onAppear {
selectedTab = store.state.selectedAppTab
}
.onChange(of: selectedTab) { v in
store.send(.setSelectedAppTab(selectedTab))
}
}
}

0 comments on commit fd715b7

Please sign in to comment.