File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Sources/ComposableArchitecture/Effects
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ extension Effect {
42
42
case let . publisher( publisher) :
43
43
return Self (
44
44
operation: . publisher(
45
- Deferred {
45
+ Deferred { [ navigationIDPath ]
46
46
( )
47
47
-> Publishers . HandleEvents <
48
48
Publishers . PrefixUntilOutput <
Original file line number Diff line number Diff line change @@ -432,5 +432,37 @@ final class EffectCancellationTests: BaseTCATestCase {
432
432
// structs in Swift have the same hash value.
433
433
XCTAssertNotEqual ( id1. hashValue, id2. hashValue)
434
434
}
435
+
436
+ func testCancellablePath( ) async throws {
437
+ let navigationIDPath = NavigationIDPath ( path: [ NavigationID ( ) ] )
438
+ let effect = withDependencies {
439
+ $0. navigationIDPath = navigationIDPath
440
+ } operation: {
441
+ Effect
442
+ . publisher {
443
+ Just ( ( ) ) . delay ( for: . seconds( 1 ) , scheduler: DispatchQueue ( label: #function) )
444
+ }
445
+ . cancellable ( id: 1 )
446
+ }
447
+ await withThrowingTaskGroup ( of: Void . self) { taskGroup in
448
+ taskGroup. addTask {
449
+ await withDependencies {
450
+ $0. navigationIDPath = NavigationIDPath ( path: [ NavigationID ( ) ] )
451
+ } operation: {
452
+ for await _ in effect. actions {
453
+ XCTFail ( )
454
+ }
455
+ }
456
+ }
457
+ taskGroup. addTask {
458
+ try await withDependencies {
459
+ $0. navigationIDPath = navigationIDPath
460
+ } operation: {
461
+ try await Task . sleep ( nanoseconds: NSEC_PER_SEC / 2 )
462
+ Task . cancel ( id: 1 )
463
+ }
464
+ }
465
+ }
466
+ }
435
467
}
436
468
#endif
You can’t perform that action at this time.
0 commit comments