Skip to content

Commit fe88c19

Browse files
committed
remove the testing bit.
1 parent d38b04e commit fe88c19

File tree

1 file changed

+40
-45
lines changed

1 file changed

+40
-45
lines changed

src/reactor/fns.js

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -156,59 +156,54 @@ exports.loadState = function(reactorState, state) {
156156
*/
157157
exports.addObserver = function(observerState, getter, handler) {
158158
// 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+
}
174163

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+
})
181173

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+
)
184180

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+
)
196194
})
197-
}
195+
})
196+
}
198197

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)
202201

203-
return {
204-
observerState: updatedObserverState,
205-
entry: entry,
206-
}
207-
} catch (e) {
208-
debugger;
202+
return {
203+
observerState: updatedObserverState,
204+
entry: entry,
209205
}
210206

211-
212207
}
213208

214209
/**

0 commit comments

Comments
 (0)