Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,15 @@ struct RootView: View {
}
}
.navigationBarTitle("Case Studies")
.onAppear { self.id = UUID() }

Text("\(self.id)")
}
.navigationViewStyle(StackNavigationViewStyle())
}
// NB: This is a hack to force the root view to re-compute itself each time it appears so that
// each demo is provided a fresh store each time.
@State var id = UUID()
}

struct RootView_Previews: PreviewProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ let lazyListNavigationReducer = Reducer<
LazyListNavigationState, LazyListNavigationAction, LazyListNavigationEnvironment
>.combine(
Reducer { state, action, environment in
struct CancelId: Hashable {}

switch action {
case .counter:
return .none
Expand All @@ -43,8 +45,6 @@ let lazyListNavigationReducer = Reducer<
state.rows[index].isActivityIndicatorVisible = state.rows[index].id == id
}

struct CancelId: Hashable {}

return Effect(value: .setNavigationSelectionDelayCompleted(id))
.delay(for: 1, scheduler: environment.mainQueue)
.eraseToEffect()
Expand All @@ -53,9 +53,9 @@ let lazyListNavigationReducer = Reducer<
case .setNavigation(selection: .none):
if let selection = state.selection {
state.rows[id: selection.id]?.count = selection.count
state.selection = nil
}
return .none
state.selection = nil
return .cancel(id: CancelId())

case let .setNavigationSelectionDelayCompleted(id):
state.rows[id: id]?.isActivityIndicatorVisible = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ let eagerListNavigationReducer = Reducer<
case .setNavigation(selection: .none):
if let selection = state.selection, let count = selection.value?.count {
state.rows[id: selection.id]?.count = count
state.selection = nil
}
state.selection = nil
return .cancel(id: CancelId())

case .setNavigationSelectionDelayCompleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Dispatch
extension Reducer {
/// Prints debug messages describing all received actions and state mutations.
///
/// Printing is only done in DEBUG builds.
/// Printing is only done in debug (`#if DEBUG`) builds.
///
/// - Parameters:
/// - prefix: A string with which to prefix all debug messages.
Expand All @@ -24,7 +24,7 @@ extension Reducer {

/// Prints debug messages describing all received actions.
///
/// Printing is only done in DEBUG builds.
/// Printing is only done in debug (`#if DEBUG`) builds.
///
/// - Parameters:
/// - prefix: A string with which to prefix all debug messages.
Expand Down