Skip to content

Commit c3f39b7

Browse files
committed
Fix build/tests, run swift-format
1 parent 2bf9e8b commit c3f39b7

19 files changed

+2557
-2555
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# ``ComposableArchitecture/EffectPublisher/send(_:)``
1+
# ``ComposableArchitecture/EffectProducer/send(_:)``
22

33
## Topics
44

55
### Animating actions
66

7-
- ``EffectPublisher/send(_:animation:)``
7+
- ``EffectProducer/send(_:animation:)``

Sources/ComposableArchitecture/Effect.swift

+27-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactiveSwift
33
import XCTestDynamicOverlay
44

55
#if canImport(SwiftUI)
6-
import SwiftUI
6+
import SwiftUI
77
#endif
88

99
/// This type is deprecated in favor of ``EffectTask``. See its documentation for more information.
@@ -115,7 +115,7 @@ extension EffectProducer {
115115
/// > This is only an issue if using the Combine interface of ``EffectProducer`` as mentioned
116116
/// > above. If you are using Swift's concurrency tools and the `.task`, `.run`, and
117117
/// > `.fireAndForget` functions on ``EffectTask``, then threading is automatically handled for you.
118-
public typealias EffectTask<Action> = EffectPublisher<Action, Never>
118+
public typealias EffectTask<Action> = EffectProducer<Action, Never>
119119

120120
extension EffectProducer where Failure == Never {
121121
/// Wraps an asynchronous unit of work in an effect.
@@ -340,20 +340,22 @@ extension EffectProducer where Failure == Never {
340340
Self(value: action)
341341
}
342342

343-
/// Initializes an effect that immediately emits the action passed in.
344-
///
345-
/// > Note: We do not recommend using `Effect.send` to share logic. Instead, limit usage to
346-
/// > child-parent communication, where a child may want to emit a "delegate" action for a parent
347-
/// > to listen to.
348-
/// >
349-
/// > For more information, see <doc:Performance#Sharing-logic-with-actions>.
350-
///
351-
/// - Parameters:
352-
/// - action: The action that is immediately emitted by the effect.
353-
/// - animation: An animation.
354-
public static func send(_ action: Action, animation: Animation? = nil) -> Self {
355-
Self(value: action).animation(animation)
356-
}
343+
#if canImport(SwiftUI)
344+
/// Initializes an effect that immediately emits the action passed in.
345+
///
346+
/// > Note: We do not recommend using `Effect.send` to share logic. Instead, limit usage to
347+
/// > child-parent communication, where a child may want to emit a "delegate" action for a parent
348+
/// > to listen to.
349+
/// >
350+
/// > For more information, see <doc:Performance#Sharing-logic-with-actions>.
351+
///
352+
/// - Parameters:
353+
/// - action: The action that is immediately emitted by the effect.
354+
/// - animation: An animation.
355+
public static func send(_ action: Action, animation: Animation? = nil) -> Self {
356+
Self(value: action).animation(animation)
357+
}
358+
#endif
357359
}
358360

359361
/// A type that can send actions back into the system when used from
@@ -401,15 +403,15 @@ public struct Send<Action> {
401403
}
402404

403405
#if canImport(SwiftUI)
404-
/// Sends an action back into the system from an effect with animation.
405-
///
406-
/// - Parameters:
407-
/// - action: An action.
408-
/// - animation: An animation.
409-
public func callAsFunction(_ action: Action, animation: Animation?) {
410-
callAsFunction(action, transaction: Transaction(animation: animation))
411-
}
412-
406+
/// Sends an action back into the system from an effect with animation.
407+
///
408+
/// - Parameters:
409+
/// - action: An action.
410+
/// - animation: An animation.
411+
public func callAsFunction(_ action: Action, animation: Animation?) {
412+
callAsFunction(action, transaction: Transaction(animation: animation))
413+
}
414+
413415
/// Sends an action back into the system from an effect with transaction.
414416
///
415417
/// - Parameters:
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
#if canImport(SwiftUI)
22
import ReactiveSwift
3-
import SwiftUI
3+
import SwiftUI
44

55
extension EffectProducer {
6-
/// Wraps the emission of each element with SwiftUI's `withAnimation`.
7-
///
8-
/// ```swift
9-
/// case .buttonTapped:
10-
/// return .task {
11-
/// .activityResponse(await self.apiClient.fetchActivity())
12-
/// }
13-
/// .animation()
14-
/// ```
15-
///
16-
/// - Parameter animation: An animation.
6+
/// Wraps the emission of each element with SwiftUI's `withAnimation`.
7+
///
8+
/// ```swift
9+
/// case .buttonTapped:
10+
/// return .task {
11+
/// .activityResponse(await self.apiClient.fetchActivity())
12+
/// }
13+
/// .animation()
14+
/// ```
15+
///
16+
/// - Parameter animation: An animation.
1717
/// - Returns: An effect.
18-
public func animation(_ animation: Animation? = .default) -> Self {
19-
self.transaction(Transaction(animation: animation))
20-
}
18+
public func animation(_ animation: Animation? = .default) -> Self {
19+
self.transaction(Transaction(animation: animation))
20+
}
2121

22-
/// Wraps the emission of each element with SwiftUI's `withTransaction`.
23-
///
24-
/// ```swift
25-
/// case .buttonTapped:
26-
/// var transaction = Transaction(animation: .default)
27-
/// transaction.disablesAnimations = true
28-
/// return .task {
29-
/// .activityResponse(await self.apiClient.fetchActivity())
30-
/// }
31-
/// .transaction(transaction)
32-
/// ```
33-
///
34-
/// - Parameter transaction: A transaction.
35-
/// - Returns: A publisher.
36-
public func transaction(_ transaction: Transaction) -> Self {
37-
switch self.operation {
38-
case .none:
39-
return .none
22+
/// Wraps the emission of each element with SwiftUI's `withTransaction`.
23+
///
24+
/// ```swift
25+
/// case .buttonTapped:
26+
/// var transaction = Transaction(animation: .default)
27+
/// transaction.disablesAnimations = true
28+
/// return .task {
29+
/// .activityResponse(await self.apiClient.fetchActivity())
30+
/// }
31+
/// .transaction(transaction)
32+
/// ```
33+
///
34+
/// - Parameter transaction: A transaction.
35+
/// - Returns: A publisher.
36+
public func transaction(_ transaction: Transaction) -> Self {
37+
switch self.operation {
38+
case .none:
39+
return .none
4040
case let .producer(producer):
41-
return Self(
41+
return Self(
4242
operation: .producer(
4343
SignalProducer<Action, Failure> { observer, _ in
4444
producer.start { action in
@@ -56,21 +56,21 @@ import SwiftUI
5656
}
5757
}
5858
}
59+
)
5960
)
60-
)
61-
case let .run(priority, operation):
62-
return Self(
63-
operation: .run(priority) { send in
64-
await operation(
65-
Send { value in
66-
withTransaction(transaction) {
67-
send(value)
61+
case let .run(priority, operation):
62+
return Self(
63+
operation: .run(priority) { send in
64+
await operation(
65+
Send { value in
66+
withTransaction(transaction) {
67+
send(value)
68+
}
6869
}
69-
}
70-
)
71-
}
72-
)
70+
)
71+
}
72+
)
73+
}
7374
}
7475
}
75-
}
7676
#endif

Sources/ComposableArchitecture/Effects/Publisher/Timer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension EffectProducer where Action == Date, Failure == Never {
4949
/// initialState: Feature.State(),
5050
/// reducer: Feature()
5151
/// ) {
52-
/// $0.mainQueue = mainQueue
52+
/// $0.mainQueueScheduler = mainQueue
5353
/// }
5454
///
5555
/// await store.send(.startButtonTapped)

0 commit comments

Comments
 (0)