Skip to content

Commit 79e03e4

Browse files
committed
wip
1 parent 32b4a8a commit 79e03e4

File tree

13 files changed

+74
-20
lines changed

13 files changed

+74
-20
lines changed

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-Lifecycle.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ struct LifecycleDemo: ReducerProtocol {
6666
private enum CancelID {}
6767

6868
var body: some ReducerProtocol<State, Action> {
69-
// TODO: timerReducer
7069
Reduce { state, action in
7170
switch action {
7271
case .timer:

Sources/ComposableArchitecture/Documentation.docc/Articles/Dependencies.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ that triggers an `XCTFail` anytime one of its endpoints is invoked. This makes i
205205
stub the bare minimum of the dependency's interface, allowing you to prove that your test flow
206206
doesn't interact with any other endpoints.
207207

208+
> Tip: To use a different, default version when your feature is run in an Xcode preview, use the
209+
> optional `previewValue` requirement.
210+
>
211+
> ```swift
212+
> extension APIClientKey {
213+
> static let previewValue = APIClient.mock(.loggedIn)
214+
> }
215+
> ```
216+
208217
Next you extend the key to also conform to the [`DependencyKey`][dependency-key-docs] protocol,
209218
which will be the version of the dependency used when your feature is run in an Xcode preview, in
210219
the simulator, or on a device:
@@ -215,8 +224,6 @@ extension APIClientKey: DependencyKey {
215224
}
216225
```
217226

218-
<!-- TODO: Document `previewValue` -->
219-
220227
This is the version of the dependency that can actually interact with outside systems. In this
221228
case it means the API client can actually make network requests to an external server.
222229

Sources/ComposableArchitecture/Documentation.docc/Extensions/Deprecations/EffectDeprecations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement
4747
- ``Effect/timer(id:every:tolerance:on:options:)-4exe6``
4848
- ``Effect/timer(id:every:tolerance:on:options:)-7po0d``
4949
- ``Effect/Subscriber``
50-
<!--TODO: Can't currently document `Publisher` extensions. -->
50+
<!--DocC: Can't currently document `Publisher` extensions. -->

Sources/ComposableArchitecture/Documentation.docc/Extensions/Deprecations/SwiftUIDeprecations.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement
88

99
## Topics
1010

11-
### `WithViewStore`
11+
### ForEachStore
12+
13+
- ``ForEachStore/init(_:content:)-34mtj``
14+
- ``ForEachStore/init(_:id:content:)``
15+
16+
### WithViewStore
1217

1318
- ``WithViewStore/init(_:content:file:line:)-1gjbi``
1419
- ``WithViewStore/init(_:content:file:line:)-2uj44``
@@ -28,9 +33,9 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement
2833
- ``WithViewStore/Action``
2934
- ``WithViewStore/State``
3035

31-
### View State
36+
### View state
3237

3338
- ``ActionSheetState``
3439

35-
<!--TODO: Can't currently document `View` extensions-->
40+
<!--DocC: Can't currently document `View` extensions-->
3641
<!--### View Modifiers-->

Sources/ComposableArchitecture/Documentation.docc/Extensions/Store.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
### Scoping stores
1111

1212
- ``scope(state:action:)``
13-
- ``stateless``
14-
- ``actionless``
1513

1614
### Combine integration
1715

Sources/ComposableArchitecture/Documentation.docc/Extensions/StoreScope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
### Overloads
66

77
- ``scope(state:)``
8+
- ``stateless``
9+
- ``actionless``

Sources/ComposableArchitecture/Documentation.docc/Extensions/SwiftUI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Composable Architecture can be used to power applications built in many fram
3131
- ``ConfirmationDialogState``
3232
- ``TextState``
3333

34-
<!--TODO: Can't currently document `View` extensions-->
34+
<!--DocC: Can't currently document `View` extensions-->
3535
<!--### View Modifiers-->
3636

3737
### Deprecations
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ``ComposableArchitecture/WithViewStore``
2+
3+
## Overview
4+
5+
## Topics
6+
7+
### Creating a view
8+
9+
- ``init(_:observe:content:file:line:)``
10+
11+
### Debugging view updates
12+
13+
- ``debug(_:)``
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ``ComposableArchitecture/WithViewStore/init(_:observe:content:file:line:)``
2+
3+
## Topics
4+
5+
### Overloads
6+
7+
- ``WithViewStore/init(_:observe:removeDuplicates:content:file:line:)``
8+
- ``WithViewStore/init(_:observe:send:content:file:line:)``
9+
- ``WithViewStore/init(_:observe:send:removeDuplicates:content:file:line:)``

Sources/ComposableArchitecture/Effects/ConcurrencySupport.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,12 @@ extension Task where Success == Never, Failure == Never {
294294
/// ```
295295
@dynamicMemberLookup
296296
public final actor ActorIsolated<Value: Sendable> {
297+
/// The actor-isolated value.
297298
public var value: Value
298299

300+
/// Initializes actor-isolated state around a value.
301+
///
302+
/// - Parameter value: A value to isolate in an actor.
299303
public init(_ value: Value) {
300304
self.value = value
301305
}
@@ -306,6 +310,17 @@ public final actor ActorIsolated<Value: Sendable> {
306310

307311
/// Perform an operation with isolated access to the underlying value.
308312
///
313+
/// Useful for inspecting an actor-isolated value for a test assertion:
314+
///
315+
/// ```swift
316+
/// let didOpenSettings = ActorIsolated(false)
317+
/// store.dependencies.openSettings = { await didOpenSettings.setValue(true) }
318+
///
319+
/// await store.send(.settingsButtonTapped)
320+
///
321+
/// await didOpenSettings.withValue { XCTAssertTrue($0) }
322+
/// ```
323+
///
309324
/// - Parameters: operation: An operation to be performed on the actor with the underlying value.
310325
/// - Returns: The result of the operation.
311326
public func withValue<T: Sendable>(
@@ -318,6 +333,17 @@ public final actor ActorIsolated<Value: Sendable> {
318333

319334
/// Overwrite the isolated value with a new value.
320335
///
336+
/// Useful for setting an actor-isolated value when a tested dependency runs.
337+
///
338+
/// ```swift
339+
/// let didOpenSettings = ActorIsolated(false)
340+
/// store.dependencies.openSettings = { await didOpenSettings.setValue(true) }
341+
///
342+
/// await store.send(.settingsButtonTapped)
343+
///
344+
/// await didOpenSettings.withValue { XCTAssertTrue($0) }
345+
/// ```
346+
///
321347
/// - Parameter newValue: The value to replace the current isolated value with.
322348
public func setValue(_ newValue: Value) {
323349
self.value = newValue
@@ -338,6 +364,7 @@ public final actor ActorIsolated<Value: Sendable> {
338364
@dynamicMemberLookup
339365
@propertyWrapper
340366
public struct UncheckedSendable<Value>: @unchecked Sendable {
367+
/// The unchecked value.
341368
public var value: Value
342369

343370
public init(_ value: Value) {

Sources/ComposableArchitecture/Store.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ public final class Store<State, Action> {
432432
self.scope(state: { _ in () })
433433
}
434434

435-
// TODO: move docs for this into overloads of scope
436435
/// Returns an "actionless" store by erasing action to `Never`.
437436
public var actionless: Store<State, Never> {
438437
func absurd<A>(_ never: Never) -> A {}

Sources/ComposableArchitecture/SwiftUI/WithViewStore.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,6 @@ extension WithViewStore where ViewState: Equatable, Content: View {
611611
}
612612

613613
extension WithViewStore where ViewState == Void, Content: View {
614-
// TODO: move docs for this init under overloads for WithViewStore
615-
616614
/// Initializes a structure that transforms a store into an observable view store in order to
617615
/// compute views from void store state.
618616
///

Tests/ComposableArchitectureTests/DebugTests.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,13 @@ final class DebugTests: XCTestCase {
206206
struct DebuggedReducer: ReducerProtocol {
207207
typealias State = Int
208208
typealias Action = Bool
209-
var body: some ReducerProtocol<State, Action> {
210-
Reduce { state, action in
211-
state += action ? 1 : -1
212-
return .none
213-
}
214-
.debug()
209+
func reduce(into state: inout Int, action: Bool) -> Effect<Bool, Never> {
210+
state += action ? 1 : -1
211+
return .none
215212
}
216213
}
217214

218-
let store = TestStore(initialState: 0, reducer: DebuggedReducer())
215+
let store = TestStore(initialState: 0, reducer: DebuggedReducer().debug())
219216
await store.send(true) { $0 = 1 }
220217
}
221218
}

0 commit comments

Comments
 (0)