@@ -63,7 +63,8 @@ public final class ViewStore<State, Action> {
6363 #endif
6464
6565 private let _send : ( Action ) -> Void
66- fileprivate let _state : MutableProperty < State >
66+ private var _state : State
67+ fileprivate let _stateSubject = Signal < State , Never > . pipe ( )
6768 private var viewDisposable : Disposable ?
6869
6970 /// Initializes a view store from a store.
@@ -76,7 +77,7 @@ public final class ViewStore<State, Action> {
7677 _ store: Store < State , Action > ,
7778 removeDuplicates isDuplicate: @escaping ( State , State ) -> Bool
7879 ) {
79- self . _state = MutableProperty ( store. $state. value)
80+ self . _state = store. $state. value
8081 self . _send = store. send
8182
8283 self . viewDisposable = store. $state. producer
@@ -88,7 +89,8 @@ public final class ViewStore<State, Action> {
8889 self . objectWillChange. send ( )
8990 }
9091 #endif
91- self . _state. value = $0
92+ self . _state = $0
93+ self . _stateSubject. input. send ( value: $0)
9294 }
9395 }
9496
@@ -99,12 +101,12 @@ public final class ViewStore<State, Action> {
99101
100102 /// The current state.
101103 public var state : State {
102- self . _state. value
104+ self . _state
103105 }
104106
105107 /// Returns the resulting value of a given key path.
106108 public subscript< LocalState> ( dynamicMember keyPath: KeyPath < State , LocalState > ) -> LocalState {
107- self . _state. value [ keyPath: keyPath]
109+ self . _state [ keyPath: keyPath]
108110 }
109111
110112 /// Sends an action to the store.
@@ -155,7 +157,7 @@ public final class ViewStore<State, Action> {
155157 send localStateToViewAction: @escaping ( LocalState ) -> Action
156158 ) -> Binding < LocalState > {
157159 Binding (
158- get: { get ( self . _state. value ) } ,
160+ get: { get ( self . _state) } ,
159161 set: { newLocalState, transaction in
160162 if transaction. animation != nil {
161163 withTransaction ( transaction) {
@@ -295,7 +297,10 @@ public struct StoreProducer<State>: SignalProducerConvertible {
295297
296298 fileprivate init < Action> ( viewStore: ViewStore < State , Action > ) {
297299 self . viewStore = viewStore
298- self . upstream = viewStore. _state. producer
300+ self . upstream = Property < State > ( initial: viewStore. state, then: viewStore. _stateSubject. output) . producer
301+ // .on(completed: { [viewStore = self.viewStore] in
302+ // _ = viewStore
303+ // })
299304 }
300305
301306 private init (
0 commit comments