Child store caching improvements (#2627)

* Use `ScopeID` for all cached child stores

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
Stephen Celis
2023-12-07 12:39:37 -08:00
committed by GitHub
parent 41f79c0c65
commit c2a27dcaad
9 changed files with 147 additions and 123 deletions

View File

@@ -20,12 +20,14 @@ extension View {
store: Store<PresentationState<State>, PresentationAction<Action>>,
@ViewBuilder destination: @escaping (_ store: Store<State, Action>) -> Destination
) -> some View {
self._navigationDestination(
self.presentation(
store: store,
state: { $0 },
action: { $0 },
destination: destination
)
id: { $0.wrappedValue.map(NavigationDestinationID.init) }
) { `self`, $item, destinationContent in
self.navigationDestination(isPresented: $item.isPresent()) {
destinationContent(destination)
}
}
}
/// Associates a destination view with a store that can be used to push the view onto a
@@ -73,23 +75,6 @@ extension View {
action fromDestinationAction: @escaping (_ destinationAction: DestinationAction) -> Action,
@ViewBuilder destination: @escaping (_ store: Store<DestinationState, DestinationAction>) ->
Destination
) -> some View {
self._navigationDestination(
store: store,
state: toDestinationState,
action: fromDestinationAction,
destination: destination
)
}
private func _navigationDestination<
State, Action, DestinationState, DestinationAction, Destination: View
>(
store: Store<PresentationState<State>, PresentationAction<Action>>,
state toDestinationState: @escaping (_ state: State) -> DestinationState?,
action fromDestinationAction: @escaping (_ destinationAction: DestinationAction) -> Action,
@ViewBuilder destination: @escaping (_ store: Store<DestinationState, DestinationAction>) ->
Destination
) -> some View {
self.presentation(
store: store,