@@ -139,7 +139,7 @@ public final class Store<State, Action> {
139139 private var isSending = false
140140 var parentCancellable : AnyCancellable ?
141141 private let reducer : any Reducer < State , Action >
142- @_spi ( Internals) public var stateSubject : CurrentValueSubject < State , Never > !
142+ @_spi ( Internals) public var stateSubject : CurrentValueSubject < State , Never >
143143 #if DEBUG
144144 private let mainThreadChecksEnabled : Bool
145145 #endif
@@ -175,14 +175,6 @@ public final class Store<State, Action> {
175175 }
176176 }
177177
178- fileprivate init ( ) {
179- self . _isInvalidated = { true }
180- self . reducer = EmptyReducer ( )
181- #if DEBUG
182- self . mainThreadChecksEnabled = true
183- #endif
184- }
185-
186178 deinit {
187179 self . invalidate ( )
188180 Logger . shared. log ( " \( storeTypeName ( of: self ) ) .deinit " )
@@ -1002,15 +994,12 @@ private final class ScopedStoreReducer<RootState, RootAction, State, Action>: Re
1002994
1003995 @inlinable
1004996 func reduce( into state: inout State , action: Action ) -> Effect < Action > {
1005- let isInvalid = self . isInvalid ( )
1006- if isInvalid {
997+ if self . isInvalid ( ) {
1007998 self . onInvalidate ( )
1008999 }
10091000 self . isSending = true
10101001 defer {
1011- if !isInvalid || state is _OptionalProtocol {
1012- state = self . toState ( self . rootStore. stateSubject. value)
1013- }
1002+ state = self . toState ( self . rootStore. stateSubject. value)
10141003 self . isSending = false
10151004 }
10161005 if let action = self . fromAction ( action) ,
@@ -1043,10 +1032,6 @@ extension ScopedStoreReducer: AnyScopedStoreReducer {
10431032 isInvalid: ( ( S ) -> Bool ) ? ,
10441033 removeDuplicates isDuplicate: ( ( ChildState , ChildState ) -> Bool ) ?
10451034 ) -> Store < ChildState , ChildAction > {
1046- guard isInvalid. map ( { $0 ( store. stateSubject. value) == false } ) ?? true
1047- else {
1048- return Store ( )
1049- }
10501035 let id = id ? ( store. stateSubject. value)
10511036 if let id = id,
10521037 let childStore = store. children [ id] as? Store < ChildState , ChildAction >
@@ -1068,7 +1053,7 @@ extension ScopedStoreReducer: AnyScopedStoreReducer {
10681053 }
10691054 let reducer = ScopedStoreReducer < RootState , RootAction , ChildState , ChildAction > (
10701055 rootStore: self . rootStore,
1071- state: { [ stateSubject = store. stateSubject! ] _ in toChildState ( stateSubject. value) } ,
1056+ state: { [ stateSubject = store. stateSubject] _ in toChildState ( stateSubject. value) } ,
10721057 action: { fromChildAction ( $0) . flatMap ( fromAction) } ,
10731058 isInvalid: isInvalid,
10741059 onInvalidate: { [ weak store] in
0 commit comments