Slide 23
Slide 23 text
@Reducer
struct Schedule {
@ObservableState
struct State: Equatable {
var path = StackState()
}
enum Action {
case path(StackActionOf)
}
var body: some View {
Reduce { state, action in
…
}
.forEach(\.path, action: \.path) {
Path()
}
}
}
extension Schedule {
@Reducer
struct Path {
@ObservableState
enum State: Equatable {
case detail(ScheduleDetail.State)
}
enum Action {
case detail(ScheduleDetail.Action)
}
var body: some ReducerOf {
Scope(state: \.detail, action: \.detail) {
ScheduleDetail()
}
}
}
}
@Reducer
struct Schedule {
@ObservableState
struct State: Equatable {
@Presents var destination: Destination.State?
}
enum Action {
case destination(PresentationAction)
}
var body: some ReducerOf {
Reduce { state, action in
…
}
.ifLet(\.$destination, action: \.destination) {
Destination()
}
}
}
extension Schedule {
@Reducer
struct Destination {
@ObservableState
enum State: Equatable {
case detail(ScheduleDetail.State)
}
enum Action {
case detail(ScheduleDetail.Action)
}
var body: some ReducerOf {
Reduce { state, action in
Scope(state: \.detail, action: \.detail) {
ScheduleDetail()
}
}
}
…