subscript(case:)
Accesses the value associated with the given case for reading and writing.
subscript<Case>(case path: CaseKeyPath<State, Case>) -> Case? where State : CasePathable { get set }
If you use the techniques of tree-based navigation (see Tree-based navigation), then you will have a single enum that determines the destinations your feature can navigate to, and you will hold onto that state using the Presents
macro:
@ObservableState
struct State {
@Presents var destination: Destination.State
}
The destination
property has a projected value of PresentationState
, which gives you a succinct syntax for modifying the data in a particular case of the Destination
enum, like so:
state.$destination[case: \.detail]?.alert = AlertState {
Text("Delete?")
}