subscript(id:case:)
Accesses the value associated with the given id and case for reading and writing.
subscript<Case>(id id: StackElementID, case path: CaseKeyPath<Element, Case>) -> Case? where Element : CasePathable { get set }
When using stack-based navigation (see Stack-based navigation) you will typically have a single enum that represents all of the destinations that can be pushed onto the stack, and you will hold that state in StackState
:
struct State {
var path = StackState<Path.State>()
}
You can use this subscript for a succinct syntax to modify the data in a particular case of the Path.State
enum, like so:
state.path[id: 0, case: \.edit]?.alert = AlertState {
Text("Delete?")
}