MacOS windows with unique data #1112
Replies: 1 comment 1 reply
-
Hello @nashysolutions!
struct LandmarkList: View {
let store: Store<State, Action>
@ObservedObject var viewStore: ViewStore<State, Action>
init(store: Store<State, Action>) {
self.store = store
self.viewStore = ViewStore(store)
}
var filteredLandmarks: [Landmark] {
viewStore.landmarks.filter { landmark in
(!viewStore.showFavoritesOnly || landmark.isFavorite)
&& (viewStore.filter == .all || viewStore.filter.rawValue == landmark.category.rawValue)
}
}
…
}
extension LandmarkListState {
var filteredLandmarks: [Landmark] {
self.landmarks.filter { landmark in
(!self.showFavoritesOnly || landmark.isFavorite)
&& (self.filter == .all || self.filter.rawValue == landmark.category.rawValue)
}
}
}
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The tutorial series located here at Apple explains that the following feature can be achieved by manipulating the model from within the view.
Different Filters in Each Window
Would this be easy to achieve using the composable architecture?
The reason I ask is because Apple recommend using a computed property on the view itself and you guys modify state within dedicated stores.
The above computed property is within the view, so when a new instance of this view is created, the output of this property will be unique for each view instance. The data remains in sync when you toggle the
isFavorite
start button.Apple Sample Code - see folder named 'complete'
CreatingAmacOSApp.zip
Beta Was this translation helpful? Give feedback.
All reactions