@@ -156,59 +156,54 @@ exports.loadState = function(reactorState, state) {
156
156
*/
157
157
exports . addObserver = function ( observerState , getter , handler ) {
158
158
// use the passed in getter as the key so we can rely on a byreference call for unobserve
159
- try {
160
- const getterKey = getter
161
- if ( isKeyPath ( getter ) ) {
162
- getter = fromKeyPath ( getter )
163
- }
164
-
165
- const currId = observerState . get ( 'nextId' )
166
- const storeDeps = getStoreDeps ( getter )
167
- const entry = Immutable . Map ( {
168
- id : currId ,
169
- storeDeps : storeDeps ,
170
- getterKey : getterKey ,
171
- getter : getter ,
172
- handler : handler ,
173
- } )
159
+ const getterKey = getter
160
+ if ( isKeyPath ( getter ) ) {
161
+ getter = fromKeyPath ( getter )
162
+ }
174
163
175
- let updatedObserverState = observerState . updateIn ( [ 'gettersMap' , getter ]
176
- , observerIds =>
177
- observerIds
178
- ? observerIds . add ( currId )
179
- : Immutable . Set ( [ ] ) . add ( currId )
180
- )
164
+ const currId = observerState . get ( 'nextId' )
165
+ const storeDeps = getStoreDeps ( getter )
166
+ const entry = Immutable . Map ( {
167
+ id : currId ,
168
+ storeDeps : storeDeps ,
169
+ getterKey : getterKey ,
170
+ getter : getter ,
171
+ handler : handler ,
172
+ } )
181
173
182
- if ( storeDeps . size === 0 ) {
183
- // no storeDeps means the observer is dependent on any of the state changing
174
+ let updatedObserverState = observerState . updateIn ( [ 'gettersMap' , getter ]
175
+ , observerIds =>
176
+ observerIds
177
+ ? observerIds . add ( currId )
178
+ : Immutable . Set ( [ ] ) . add ( currId )
179
+ )
184
180
185
- updatedObserverState = updatedObserverState . updateIn ( [ 'any' ] , getters => getters . add ( getter ) )
186
- } else {
187
- updatedObserverState = updatedObserverState . withMutations ( map => {
188
- storeDeps . forEach ( storeId => {
189
- map . updateIn ( [ 'stores' , storeId ]
190
- , getters =>
191
- getters
192
- ? getters . add ( getter )
193
- : Immutable . Set ( [ ] ) . add ( getter )
194
- )
195
- } )
181
+ if ( storeDeps . size === 0 ) {
182
+ // no storeDeps means the observer is dependent on any of the state changing
183
+
184
+ updatedObserverState = updatedObserverState . updateIn ( [ 'any' ] , getters => getters . add ( getter ) )
185
+ } else {
186
+ updatedObserverState = updatedObserverState . withMutations ( map => {
187
+ storeDeps . forEach ( storeId => {
188
+ map . updateIn ( [ 'stores' , storeId ]
189
+ , getters =>
190
+ getters
191
+ ? getters . add ( getter )
192
+ : Immutable . Set ( [ ] ) . add ( getter )
193
+ )
196
194
} )
197
- }
195
+ } )
196
+ }
198
197
199
- updatedObserverState = updatedObserverState
200
- . set ( 'nextId' , currId + 1 )
201
- . setIn ( [ 'observersMap' , currId ] , entry )
198
+ updatedObserverState = updatedObserverState
199
+ . set ( 'nextId' , currId + 1 )
200
+ . setIn ( [ 'observersMap' , currId ] , entry )
202
201
203
- return {
204
- observerState : updatedObserverState ,
205
- entry : entry ,
206
- }
207
- } catch ( e ) {
208
- debugger ;
202
+ return {
203
+ observerState : updatedObserverState ,
204
+ entry : entry ,
209
205
}
210
206
211
-
212
207
}
213
208
214
209
/**
0 commit comments