Skip to content

Commit 6738d17

Browse files
committed
Clean-up pass for DocC (#599)
1 parent 154ce46 commit 6738d17

16 files changed

+508
-459
lines changed

Sources/ComposableArchitecture/Effect.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension Effect {
2929
.deferred { () -> SignalProducer<Value, Error> in
3030
work()
3131
return .empty
32-
}
32+
}
3333
}
3434

3535
/// Concatenates a variadic list of effects together into a single effect, which runs the effects
@@ -87,14 +87,14 @@ extension Effect {
8787
/// Note that you can only deliver a single value to the `callback`. If you send more they will be
8888
/// discarded:
8989
///
90-
/// ```swift
90+
/// ```swift
9191
/// Effect<Int, Never>.future { callback in
9292
/// DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
9393
/// callback(.success(42))
9494
/// callback(.success(1729)) // Will not be emitted by the effect
9595
/// }
96-
/// }
97-
/// ```
96+
/// }
97+
/// ```
9898
///
9999
/// - Parameter attemptToFulfill: A closure that takes a `callback` as an argument which can be
100100
/// used to feed it `Result<Output, Failure>` values.
@@ -110,8 +110,8 @@ extension Effect {
110110
case let .failure(error):
111111
observer.send(error: error)
112112
}
113-
}
114-
}
113+
}
114+
}
115115
}
116116

117117
/// Turns any publisher into an ``Effect`` that cannot fail by wrapping its output and failure in
@@ -120,12 +120,12 @@ extension Effect {
120120
/// This can be useful when you are working with a failing API but want to deliver its data to an
121121
/// action that handles both success and failure.
122122
///
123-
/// ```swift
124-
/// case .buttonTapped:
125-
/// return fetchUser(id: 1)
126-
/// .catchToEffect()
127-
/// .map(ProfileAction.userResponse)
128-
/// ```
123+
/// ```swift
124+
/// case .buttonTapped:
125+
/// return fetchUser(id: 1)
126+
/// .catchToEffect()
127+
/// .map(ProfileAction.userResponse)
128+
/// ```
129129
///
130130
/// - Returns: An effect that wraps `self`.
131131
public func catchToEffect() -> Effect<Result<Value, Error>, Never> {
@@ -139,11 +139,11 @@ extension Effect {
139139
/// This is useful for times you want to fire off an effect but don't want to feed any data back
140140
/// into the system. It can automatically promote an effect to your reducer's domain.
141141
///
142-
/// ```swift
143-
/// case .buttonTapped:
144-
/// return analyticsClient.track("Button Tapped")
145-
/// .fireAndForget()
146-
/// ```
142+
/// ```swift
143+
/// case .buttonTapped:
144+
/// return analyticsClient.track("Button Tapped")
145+
/// .fireAndForget()
146+
/// ```
147147
///
148148
/// - Parameters:
149149
/// - outputType: An output type.

Sources/ComposableArchitecture/Effects/Cancellation.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ extension Effect {
1919
/// value can be used for the identifier, such as a string, but you can add a bit of protection
2020
/// against typos by defining a new type that conforms to `Hashable`, such as an empty struct:
2121
///
22-
/// ```swift
23-
/// struct LoadUserId: Hashable {}
22+
/// ```swift
23+
/// struct LoadUserId: Hashable {}
2424
///
25-
/// case .reloadButtonTapped:
26-
/// // Start a new effect to load the user
27-
/// return environment.loadUser
28-
/// .map(Action.userResponse)
29-
/// .cancellable(id: LoadUserId(), cancelInFlight: true)
25+
/// case .reloadButtonTapped:
26+
/// // Start a new effect to load the user
27+
/// return environment.loadUser
28+
/// .map(Action.userResponse)
29+
/// .cancellable(id: LoadUserId(), cancelInFlight: true)
3030
///
31-
/// case .cancelButtonTapped:
32-
/// // Cancel any in-flight requests to load the user
33-
/// return .cancel(id: LoadUserId())
34-
/// ```
31+
/// case .cancelButtonTapped:
32+
/// // Cancel any in-flight requests to load the user
33+
/// return .cancel(id: LoadUserId())
34+
/// ```
3535
///
3636
/// - Parameters:
3737
/// - id: The effect's identifier.

Sources/ComposableArchitecture/Effects/Debouncing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension Effect {
1818
/// .map(Action.searchResponse)
1919
/// .debounce(id: SearchId(), for: 0.5, scheduler: environment.mainQueue)
2020
/// ```
21-
///
21+
///
2222
/// - Parameters:
2323
/// - id: The effect's identifier.
2424
/// - dueTime: The duration you want to debounce for.

Sources/ComposableArchitecture/Effects/Timer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension Effect where Value == Date, Error == Never {
5050
/// let store = TestStore(
5151
/// initialState: .init(),
5252
/// reducer: appReducer,
53-
/// envirnoment: .init(
53+
/// environment: .init(
5454
/// mainQueue: scheduler
5555
/// )
5656
/// )
@@ -87,6 +87,6 @@ extension Effect where Value == Date, Error == Never {
8787
return SignalProducer.timer(
8888
interval: interval, on: scheduler, leeway: tolerance ?? .seconds(.max)
8989
)
90-
.cancellable(id: id, cancelInFlight: true)
90+
.cancellable(id: id, cancelInFlight: true)
9191
}
9292
}

Sources/ComposableArchitecture/Reducer.swift

Lines changed: 104 additions & 65 deletions
Large diffs are not rendered by default.

Sources/ComposableArchitecture/Store.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ import ReactiveSwift
9090
/// sometimes you are required to do work synchronously, such as in animation blocks.
9191
///
9292
/// * It is possible to create a scheduler that performs its work immediately when on the main
93-
/// thread and otherwise uses `DispatchQueue.main.async` (e.g. see CombineScheduler's [UIScheduler](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift)). This introduces a lot more complexity, and should probably not be adopted without having a very
93+
/// thread and otherwise uses `DispatchQueue.main.async` (e.g. see CombineScheduler's
94+
/// [UIScheduler](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift)).
95+
/// This introduces a lot more complexity, and should probably not be adopted without having a very
9496
/// good reason.
9597
///
9698
/// This is why we require all actions be sent from the same thread. This requirement is in the same

Sources/ComposableArchitecture/SwiftUI/ActionSheet.swift

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,99 +14,99 @@ import SwiftUI
1414
///
1515
/// To use this API, you model all the action sheet actions in your domain's action enum:
1616
///
17-
/// ```swift
18-
/// enum AppAction: Equatable {
19-
/// case cancelTapped
20-
/// case deleteTapped
21-
/// case favoriteTapped
22-
/// case infoTapped
17+
/// ```swift
18+
/// enum AppAction: Equatable {
19+
/// case cancelTapped
20+
/// case deleteTapped
21+
/// case favoriteTapped
22+
/// case infoTapped
2323
///
24-
/// // Your other actions
25-
/// }
26-
/// ```
24+
/// // Your other actions
25+
/// }
26+
/// ```
2727
///
2828
/// And you model the state for showing the action sheet in your domain's state, and it can start
2929
/// off in a `nil` state:
3030
///
31-
/// ```swift
32-
/// struct AppState: Equatable {
33-
/// var actionSheet: ActionSheetState<AppAction>?
31+
/// ```swift
32+
/// struct AppState: Equatable {
33+
/// var actionSheet: ActionSheetState<AppAction>?
3434
///
35-
/// // Your other state
36-
/// }
37-
/// ```
35+
/// // Your other state
36+
/// }
37+
/// ```
3838
///
3939
/// Then, in the reducer you can construct an `ActionSheetState` value to represent the action
4040
/// sheet you want to show to the user:
4141
///
42-
/// ```swift
43-
/// let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, env in
44-
/// switch action
45-
/// case .cancelTapped:
46-
/// state.actionSheet = nil
47-
/// return .none
48-
///
49-
/// case .deleteTapped:
50-
/// state.actionSheet = nil
51-
/// // Do deletion logic...
52-
///
53-
/// case .favoriteTapped:
54-
/// state.actionSheet = nil
55-
/// // Do favoriting logic
56-
///
57-
/// case .infoTapped:
58-
/// state.actionSheet = .init(
59-
/// title: "What would you like to do?",
60-
/// buttons: [
61-
/// .default(TextState("Favorite"), send: .favoriteTapped),
62-
/// .destructive(TextState("Delete"), send: .deleteTapped),
63-
/// .cancel(),
64-
/// ]
65-
/// )
66-
/// return .none
67-
/// }
68-
/// }
69-
/// ```
42+
/// ```swift
43+
/// let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, env in
44+
/// switch action
45+
/// case .cancelTapped:
46+
/// state.actionSheet = nil
47+
/// return .none
48+
///
49+
/// case .deleteTapped:
50+
/// state.actionSheet = nil
51+
/// // Do deletion logic...
52+
///
53+
/// case .favoriteTapped:
54+
/// state.actionSheet = nil
55+
/// // Do favoriting logic
56+
///
57+
/// case .infoTapped:
58+
/// state.actionSheet = .init(
59+
/// title: "What would you like to do?",
60+
/// buttons: [
61+
/// .default(TextState("Favorite"), send: .favoriteTapped),
62+
/// .destructive(TextState("Delete"), send: .deleteTapped),
63+
/// .cancel(),
64+
/// ]
65+
/// )
66+
/// return .none
67+
/// }
68+
/// }
69+
/// ```
7070
///
7171
/// And then, in your view you can use the `.actionSheet(_:send:dismiss:)` method on `View` in order
7272
/// to present the action sheet in a way that works best with the Composable Architecture:
7373
///
74-
/// ```swift
75-
/// Button("Info") { viewStore.send(.infoTapped) }
76-
/// .actionSheet(
77-
/// self.store.scope(state: \.actionSheet),
78-
/// dismiss: .cancelTapped
79-
/// )
80-
/// ```
74+
/// ```swift
75+
/// Button("Info") { viewStore.send(.infoTapped) }
76+
/// .actionSheet(
77+
/// self.store.scope(state: \.actionSheet),
78+
/// dismiss: .cancelTapped
79+
/// )
80+
/// ```
8181
///
8282
/// This makes your reducer in complete control of when the action sheet is shown or dismissed, and
8383
/// makes it so that any choice made in the action sheet is automatically fed back into the reducer
8484
/// so that you can handle its logic.
8585
///
8686
/// Even better, you can instantly write tests that your action sheet behavior works as expected:
8787
///
88-
/// ```swift
89-
/// let store = TestStore(
90-
/// initialState: AppState(),
91-
/// reducer: appReducer,
92-
/// environment: .mock
93-
/// )
94-
///
95-
/// store.send(.infoTapped) {
96-
/// $0.actionSheet = .init(
97-
/// title: "What would you like to do?",
98-
/// buttons: [
99-
/// .default(TextState("Favorite"), send: .favoriteTapped),
100-
/// .destructive(TextState("Delete"), send: .deleteTapped),
101-
/// .cancel(),
102-
/// ]
103-
/// )
104-
/// }
105-
/// store.send(.favoriteTapped) {
106-
/// $0.actionSheet = nil
107-
/// // Also verify that favoriting logic executed correctly
108-
/// }
109-
/// ```
88+
/// ```swift
89+
/// let store = TestStore(
90+
/// initialState: AppState(),
91+
/// reducer: appReducer,
92+
/// environment: .mock
93+
/// )
94+
///
95+
/// store.send(.infoTapped) {
96+
/// $0.actionSheet = .init(
97+
/// title: "What would you like to do?",
98+
/// buttons: [
99+
/// .default(TextState("Favorite"), send: .favoriteTapped),
100+
/// .destructive(TextState("Delete"), send: .deleteTapped),
101+
/// .cancel(),
102+
/// ]
103+
/// )
104+
/// }
105+
/// store.send(.favoriteTapped) {
106+
/// $0.actionSheet = nil
107+
/// // Also verify that favoriting logic executed correctly
108+
/// }
109+
/// ```
110110
///
111111
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
112112
public struct ActionSheetState<Action> {

0 commit comments

Comments
 (0)