File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Sources/ComposableArchitecture
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ import SwiftUI
9
9
import os
10
10
#endif
11
11
12
+ // NB: Deprecated after 0.36.0:
13
+
14
+ extension ViewStore {
15
+ @available ( * , deprecated, renamed: " yield(while:) " )
16
+ public func suspend( while predicate: @escaping ( State ) -> Bool ) async {
17
+ await self . yield ( while: predicate)
18
+ }
19
+ }
20
+
12
21
// NB: Deprecated after 0.34.0:
13
22
14
23
extension Effect {
Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ private struct HashableWrapper<Value>: Hashable {
453
453
while predicate: @escaping ( State ) -> Bool
454
454
) async {
455
455
self . send ( action)
456
- await self . suspend ( while: predicate)
456
+ await self . yield ( while: predicate)
457
457
}
458
458
459
459
#if canImport(SwiftUI)
@@ -472,15 +472,18 @@ private struct HashableWrapper<Value>: Hashable {
472
472
while predicate: @escaping ( State ) -> Bool
473
473
) async {
474
474
withAnimation ( animation) { self . send ( action) }
475
- await self . suspend ( while: predicate)
475
+ await self . yield ( while: predicate)
476
476
}
477
477
#endif
478
478
479
- /// Suspends while a predicate on state is `true`.
479
+ /// Suspends the current task while a predicate on state is `true`.
480
+ ///
481
+ /// If you want to suspend at the same time you send an action to the view store, use
482
+ /// ``send(_:while:)``.
480
483
///
481
484
/// - Parameter predicate: A predicate on `State` that determines for how long this method
482
485
/// should suspend.
483
- public func suspend ( while predicate: @escaping ( State ) -> Bool ) async {
486
+ public func yield ( while predicate: @escaping ( State ) -> Bool ) async {
484
487
let cancellable = Box < Disposable ? > ( wrappedValue: nil )
485
488
try ? await withTaskCancellationHandler (
486
489
handler: { cancellable. wrappedValue? . dispose ( ) } ,
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ final class ViewStoreTests: XCTestCase {
227
227
XCTAssertNoDifference ( viewStore. state, false )
228
228
viewStore. send ( . tapped)
229
229
XCTAssertNoDifference ( viewStore. state, true )
230
- await viewStore. suspend ( while: { $0 } )
230
+ await viewStore. yield ( while: { $0 } )
231
231
XCTAssertNoDifference ( viewStore. state, false )
232
232
expectation. fulfill ( )
233
233
}
You can’t perform that action at this time.
0 commit comments