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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ struct OptionalBasicsView: View {
.buttonStyle(BorderlessButtonStyle())
}
},
else: Text(template: "`CounterState` is `nil`", .body)
else: {
Text(template: "`CounterState` is `nil`", .body)
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct NavigateAndLoadListView: View {
self.store.scope(
state: { $0.selection?.value }, action: NavigateAndLoadListAction.counter),
then: CounterView.init(store:),
else: ActivityIndicator()
else: { ActivityIndicator() }
),
tag: row.id,
selection: viewStore.binding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct NavigateAndLoadView: View {
self.store.scope(
state: { $0.optionalCounter }, action: NavigateAndLoadAction.optionalCounter),
then: CounterView.init(store:),
else: ActivityIndicator()
else: { ActivityIndicator() }
),
isActive: viewStore.binding(
get: { $0.isNavigationActive },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct PresentAndLoadView: View {
self.store.scope(
state: { $0.optionalCounter }, action: PresentAndLoadAction.optionalCounter),
then: CounterView.init(store:),
else: ActivityIndicator()
else: { ActivityIndicator() }
)
}
.navigationBarTitle("Present and load")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class IfLetStoreController<State, Action>: UIViewController {
init(
store: Store<State?, Action>,
then ifDestination: @escaping (Store<State, Action>) -> UIViewController,
else elseDestination: @autoclosure @escaping () -> UIViewController
else elseDestination: @escaping () -> UIViewController
) {
self.store = store
self.ifDestination = ifDestination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class EagerNavigationViewController: UIViewController {
store: self.store
.scope(state: { $0.optionalCounter }, action: EagerNavigationAction.optionalCounter),
then: CounterViewController.init(store:),
else: ActivityIndicatorViewController()
else: ActivityIndicatorViewController.init
),
animated: true
)
Expand Down
13 changes: 13 additions & 0 deletions Sources/ComposableArchitecture/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import Combine
import SwiftUI

// NB: Deprecated after 0.17.0:

extension IfLetStore {
@available(*, deprecated, message: "'else' now takes a view builder closure")
public init<IfContent, ElseContent>(
_ store: Store<State?, Action>,
@ViewBuilder then ifContent: @escaping (Store<State, Action>) -> IfContent,
else elseContent: @escaping @autoclosure () -> ElseContent
) where Content == _ConditionalContent<IfContent, ElseContent> {
self.init(store, then: ifContent, else: elseContent)
}
}

// NB: Deprecated after 0.13.0:

@available(*, deprecated, renamed: "BindingAction")
Expand Down
6 changes: 3 additions & 3 deletions Sources/ComposableArchitecture/SwiftUI/ForEachStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where Data: Collection, ID: Hashable, Content: View {
public init<EachContent>(
_ store: Store<Data, (Data.Index, EachAction)>,
id: KeyPath<EachState, ID>,
content: @escaping (Store<EachState, EachAction>) -> EachContent
@ViewBuilder content: @escaping (Store<EachState, EachAction>) -> EachContent
)
where
Data == [EachState],
Expand Down Expand Up @@ -104,7 +104,7 @@ where Data: Collection, ID: Hashable, Content: View {
/// - content: A function that can generate content given a store of an element.
public init<EachContent>(
_ store: Store<Data, (Data.Index, EachAction)>,
content: @escaping (Store<EachState, EachAction>) -> EachContent
@ViewBuilder content: @escaping (Store<EachState, EachAction>) -> EachContent
)
where
Data == [EachState],
Expand All @@ -126,7 +126,7 @@ where Data: Collection, ID: Hashable, Content: View {
/// - content: A function that can generate content given a store of an element.
public init<EachContent: View>(
_ store: Store<IdentifiedArray<ID, EachState>, (ID, EachAction)>,
content: @escaping (Store<EachState, EachAction>) -> EachContent
@ViewBuilder content: @escaping (Store<EachState, EachAction>) -> EachContent
)
where
EachContent: View,
Expand Down
8 changes: 4 additions & 4 deletions Sources/ComposableArchitecture/SwiftUI/IfLetStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// IfLetStore(
/// store.scope(state: \SearchState.results, action: SearchAction.results),
/// then: SearchResultsView.init(store:),
/// else: Text("Loading search results...")
/// else: { Text("Loading search results...") }
/// )
///
/// And for performing navigation when a piece of state becomes non-`nil`:
Expand Down Expand Up @@ -42,8 +42,8 @@ public struct IfLetStore<State, Action, Content>: View where Content: View {
/// - elseContent: A view that is only visible when the optional state is `nil`.
public init<IfContent, ElseContent>(
_ store: Store<State?, Action>,
then ifContent: @escaping (Store<State, Action>) -> IfContent,
else elseContent: @escaping @autoclosure () -> ElseContent
@ViewBuilder then ifContent: @escaping (Store<State, Action>) -> IfContent,
@ViewBuilder else elseContent: @escaping () -> ElseContent
) where Content == _ConditionalContent<IfContent, ElseContent> {
self.store = store
self.content = { viewStore in
Expand All @@ -64,7 +64,7 @@ public struct IfLetStore<State, Action, Content>: View where Content: View {
/// is visible only when the optional state is non-`nil`.
public init<IfContent>(
_ store: Store<State?, Action>,
then ifContent: @escaping (Store<State, Action>) -> IfContent
@ViewBuilder then ifContent: @escaping (Store<State, Action>) -> IfContent
) where Content == IfContent? {
self.store = store
self.content = { viewStore in
Expand Down