File tree 3 files changed +32
-35
lines changed
Sources/ComposableArchitecture/Observation
Tests/ComposableArchitectureTests
3 files changed +32
-35
lines changed Original file line number Diff line number Diff line change 375
375
}
376
376
set {
377
377
if newValue == nil ,
378
- let childState = self . state [ keyPath: state] ,
379
- !isEphemeral( childState) ,
378
+ self . state [ keyPath: state] != nil ,
380
379
!self . _isInvalidated ( )
381
380
{
382
381
self . send ( action ( . dismiss) )
Original file line number Diff line number Diff line change @@ -2653,6 +2653,37 @@ final class PresentationReducerTests: BaseTCATestCase {
2653
2653
$0. child? . child = nil
2654
2654
}
2655
2655
}
2656
+
2657
+ @Reducer
2658
+ struct TestEphemeralBindingDismissalFeature {
2659
+ @ObservableState
2660
+ struct State : Equatable {
2661
+ @Presents var alert : AlertState < Never > ?
2662
+ }
2663
+ enum Action : Equatable {
2664
+ case alert( PresentationAction < Never > )
2665
+ }
2666
+ var body : some ReducerOf < Self > {
2667
+ Reduce { state, action in
2668
+ return . none
2669
+ }
2670
+ . ifLet ( \. $alert, action: / Action. alert)
2671
+ }
2672
+ }
2673
+ @MainActor
2674
+ func testEphemeralBindingDismissal( ) async {
2675
+ @Perception . Bindable var store = Store (
2676
+ initialState: TestEphemeralBindingDismissalFeature . State (
2677
+ alert: AlertState { TextState ( " Oops! " ) }
2678
+ )
2679
+ ) {
2680
+ TestEphemeralBindingDismissalFeature ( )
2681
+ }
2682
+
2683
+ XCTAssertNotNil ( store. alert)
2684
+ $store. scope ( state: \. alert, action: \. alert) . wrappedValue = nil
2685
+ XCTAssertNil ( store. alert)
2686
+ }
2656
2687
}
2657
2688
2658
2689
@Reducer
Original file line number Diff line number Diff line change 324
324
"""
325
325
}
326
326
}
327
-
328
- @Reducer
329
- struct TestStoreDestination_NotIntegrated_EphemeralState {
330
- @Reducer
331
- struct Destination { }
332
- @ObservableState
333
- struct State : Equatable {
334
- @Presents var alert : AlertState < Never > ?
335
- }
336
- enum Action {
337
- case alert( PresentationAction < Never > )
338
- }
339
- }
340
- @MainActor
341
- func testStoreDestination_NotIntegrated_EphemeralState( ) {
342
- let store = Store (
343
- initialState: TestStoreDestination_NotIntegrated_EphemeralState . State (
344
- alert: . init( title: { TextState ( " Hi " ) } )
345
- )
346
- ) {
347
- TestStoreDestination_NotIntegrated_EphemeralState ( )
348
- }
349
-
350
- store [
351
- state: \. alert,
352
- action: \. alert,
353
- isInViewBody: false ,
354
- fileID: " file.swift " ,
355
- filePath: " /file.swift " ,
356
- line: 1 ,
357
- column: 1
358
- ] = nil // NB: Not issue reported
359
- }
360
327
}
361
328
#endif
You can’t perform that action at this time.
0 commit comments