File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Sources/ComposableArchitecture/Effects
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ import ReactiveSwift
104
104
}
105
105
106
106
/// Creates an effect that executes some work in the real world that doesn't need to feed data
107
- /// back into the store.
107
+ /// back into the store. If an error is thrown, the effect will complete and the error will be ignored.
108
108
///
109
109
/// - Parameters:
110
110
/// - priority: Priority of the underlying task. If `nil`, the priority will come from
@@ -113,9 +113,9 @@ import ReactiveSwift
113
113
/// - Returns: An effect.
114
114
public static func fireAndForget(
115
115
priority: TaskPriority ? = nil ,
116
- _ work: @escaping @Sendable ( ) async -> Void
116
+ _ work: @escaping @Sendable ( ) async throws -> Void
117
117
) -> Effect {
118
- Effect < Void , Never > . task ( priority: priority) { await work ( ) }
118
+ Effect < Void , Never > . task ( priority: priority) { try ? await work ( ) }
119
119
. fireAndForget ( )
120
120
}
121
121
}
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ final class EffectTests: XCTestCase {
249
249
. start ( )
250
250
251
251
disposable. dispose ( )
252
+
252
253
_ = XCTWaiter . wait ( for: [ . init( ) ] , timeout: 1.1 )
253
254
}
254
255
@@ -262,14 +263,15 @@ final class EffectTests: XCTestCase {
262
263
return 42
263
264
}
264
265
265
- Effect < Int , Never > . task { await work ( ) }
266
- . sink (
267
- receiveCompletion : { _ in XCTFail ( ) } ,
268
- receiveValue : { _ in XCTFail ( ) }
266
+ let disposable = Effect < Int , Never > . task { await work ( ) }
267
+ . on (
268
+ completed : { XCTFail ( ) } ,
269
+ value : { _ in XCTFail ( ) }
269
270
)
270
- . store ( in: & self . cancellables)
271
+ . start ( on: QueueScheduler . main)
272
+ . start ( )
271
273
272
- self . cancellables = [ ]
274
+ disposable . dispose ( )
273
275
274
276
_ = XCTWaiter . wait ( for: [ . init( ) ] , timeout: 1.1 )
275
277
}
You can’t perform that action at this time.
0 commit comments