mobx 6.3.10 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +1 -0
  3. package/dist/api/tojs.d.ts +4 -1
  4. package/dist/errors.d.ts +2 -2
  5. package/dist/mobx.cjs.development.js +995 -304
  6. package/dist/mobx.cjs.development.js.map +1 -1
  7. package/dist/mobx.cjs.production.min.js +1 -1
  8. package/dist/mobx.cjs.production.min.js.map +1 -1
  9. package/dist/mobx.esm.development.js +995 -304
  10. package/dist/mobx.esm.development.js.map +1 -1
  11. package/dist/mobx.esm.js +1010 -307
  12. package/dist/mobx.esm.js.map +1 -1
  13. package/dist/mobx.esm.production.min.js +1 -1
  14. package/dist/mobx.esm.production.min.js.map +1 -1
  15. package/dist/mobx.umd.development.js +995 -304
  16. package/dist/mobx.umd.development.js.map +1 -1
  17. package/dist/mobx.umd.production.min.js +1 -1
  18. package/dist/mobx.umd.production.min.js.map +1 -1
  19. package/dist/types/observablemap.d.ts +2 -2
  20. package/dist/utils/utils.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/api/action.ts +8 -3
  23. package/src/api/annotation.ts +1 -2
  24. package/src/api/autorun.ts +22 -8
  25. package/src/api/computed.ts +5 -2
  26. package/src/api/configure.ts +6 -2
  27. package/src/api/extendobservable.ts +11 -5
  28. package/src/api/extras.ts +4 -2
  29. package/src/api/flow.ts +11 -4
  30. package/src/api/intercept-read.ts +4 -2
  31. package/src/api/intercept.ts +5 -2
  32. package/src/api/iscomputed.ts +10 -4
  33. package/src/api/isobservable.ts +10 -4
  34. package/src/api/makeObservable.ts +4 -2
  35. package/src/api/object-api.ts +30 -16
  36. package/src/api/observable.ts +23 -9
  37. package/src/api/observe.ts +4 -2
  38. package/src/api/tojs.ts +11 -4
  39. package/src/api/trace.ts +6 -2
  40. package/src/api/when.ts +12 -5
  41. package/src/core/action.ts +8 -3
  42. package/src/core/computedvalue.ts +29 -9
  43. package/src/core/derivation.ts +25 -9
  44. package/src/core/globalstate.ts +18 -7
  45. package/src/core/observable.ts +14 -5
  46. package/src/core/reaction.ts +15 -6
  47. package/src/core/spy.ts +20 -7
  48. package/src/errors.ts +2 -2
  49. package/src/types/actionannotation.ts +2 -2
  50. package/src/types/dynamicobject.ts +10 -4
  51. package/src/types/flowannotation.ts +14 -4
  52. package/src/types/intercept-utils.ts +9 -3
  53. package/src/types/legacyobservablearray.ts +5 -3
  54. package/src/types/listen-utils.ts +6 -2
  55. package/src/types/modifiers.ts +39 -14
  56. package/src/types/observablearray.ts +78 -30
  57. package/src/types/observablemap.ts +65 -26
  58. package/src/types/observableobject.ts +52 -18
  59. package/src/types/observableset.ts +29 -10
  60. package/src/types/observablevalue.ts +13 -5
  61. package/src/types/type-utils.ts +33 -11
  62. package/src/utils/comparer.ts +4 -4
  63. package/src/utils/eq.ts +45 -15
  64. package/src/utils/utils.ts +42 -20
@@ -23,13 +23,23 @@ export interface IEnhancer<T> {
23
23
 
24
24
  export function deepEnhancer(v, _, name) {
25
25
  // it is an observable already, done
26
- if (isObservable(v)) return v
26
+ if (isObservable(v)) {
27
+ return v
28
+ }
27
29
 
28
30
  // something that can be converted and mutated?
29
- if (Array.isArray(v)) return observable.array(v, { name })
30
- if (isPlainObject(v)) return observable.object(v, undefined, { name })
31
- if (isES6Map(v)) return observable.map(v, { name })
32
- if (isES6Set(v)) return observable.set(v, { name })
31
+ if (Array.isArray(v)) {
32
+ return observable.array(v, { name })
33
+ }
34
+ if (isPlainObject(v)) {
35
+ return observable.object(v, undefined, { name })
36
+ }
37
+ if (isES6Map(v)) {
38
+ return observable.map(v, { name })
39
+ }
40
+ if (isES6Set(v)) {
41
+ return observable.set(v, { name })
42
+ }
33
43
  if (typeof v === "function" && !isAction(v) && !isFlow(v)) {
34
44
  if (isGenerator(v)) {
35
45
  return flow(v)
@@ -41,18 +51,30 @@ export function deepEnhancer(v, _, name) {
41
51
  }
42
52
 
43
53
  export function shallowEnhancer(v, _, name): any {
44
- if (v === undefined || v === null) return v
45
- if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v))
54
+ if (v === undefined || v === null) {
55
+ return v
56
+ }
57
+ if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {
46
58
  return v
47
- if (Array.isArray(v)) return observable.array(v, { name, deep: false })
48
- if (isPlainObject(v)) return observable.object(v, undefined, { name, deep: false })
49
- if (isES6Map(v)) return observable.map(v, { name, deep: false })
50
- if (isES6Set(v)) return observable.set(v, { name, deep: false })
59
+ }
60
+ if (Array.isArray(v)) {
61
+ return observable.array(v, { name, deep: false })
62
+ }
63
+ if (isPlainObject(v)) {
64
+ return observable.object(v, undefined, { name, deep: false })
65
+ }
66
+ if (isES6Map(v)) {
67
+ return observable.map(v, { name, deep: false })
68
+ }
69
+ if (isES6Set(v)) {
70
+ return observable.set(v, { name, deep: false })
71
+ }
51
72
 
52
- if (__DEV__)
73
+ if (__DEV__) {
53
74
  die(
54
75
  "The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets"
55
76
  )
77
+ }
56
78
  }
57
79
 
58
80
  export function referenceEnhancer(newValue?) {
@@ -61,8 +83,11 @@ export function referenceEnhancer(newValue?) {
61
83
  }
62
84
 
63
85
  export function refStructEnhancer(v, oldValue): any {
64
- if (__DEV__ && isObservable(v))
86
+ if (__DEV__ && isObservable(v)) {
65
87
  die(`observable.struct should not be used with observable values`)
66
- if (deepEqual(v, oldValue)) return oldValue
88
+ }
89
+ if (deepEqual(v, oldValue)) {
90
+ return oldValue
91
+ }
67
92
  return v
68
93
  }
@@ -84,8 +84,12 @@ export interface IArrayWillSplice<T = any> {
84
84
  const arrayTraps = {
85
85
  get(target, name) {
86
86
  const adm: ObservableArrayAdministration = target[$mobx]
87
- if (name === $mobx) return adm
88
- if (name === "length") return adm.getArrayLength_()
87
+ if (name === $mobx) {
88
+ return adm
89
+ }
90
+ if (name === "length") {
91
+ return adm.getArrayLength_()
92
+ }
89
93
  if (typeof name === "string" && !isNaN(name as any)) {
90
94
  return adm.get_(parseInt(name))
91
95
  }
@@ -113,7 +117,8 @@ const arrayTraps = {
113
117
  }
114
118
 
115
119
  export class ObservableArrayAdministration
116
- implements IInterceptable<IArrayWillChange<any> | IArrayWillSplice<any>>, IListenable {
120
+ implements IInterceptable<IArrayWillChange<any> | IArrayWillSplice<any>>, IListenable
121
+ {
117
122
  atom_: IAtom
118
123
  readonly values_: any[] = [] // this is the prop that gets proxied, so can't replace it!
119
124
  interceptors_
@@ -135,13 +140,16 @@ export class ObservableArrayAdministration
135
140
  }
136
141
 
137
142
  dehanceValue_(value: any): any {
138
- if (this.dehancer !== undefined) return this.dehancer(value)
143
+ if (this.dehancer !== undefined) {
144
+ return this.dehancer(value)
145
+ }
139
146
  return value
140
147
  }
141
148
 
142
149
  dehanceValues_(values: any[]): any[] {
143
- if (this.dehancer !== undefined && values.length > 0)
150
+ if (this.dehancer !== undefined && values.length > 0) {
144
151
  return values.map(this.dehancer) as any
152
+ }
145
153
  return values
146
154
  }
147
155
 
@@ -175,36 +183,56 @@ export class ObservableArrayAdministration
175
183
  }
176
184
 
177
185
  setArrayLength_(newLength: number) {
178
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0)
186
+ if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
179
187
  die("Out of range: " + newLength)
188
+ }
180
189
  let currentLength = this.values_.length
181
- if (newLength === currentLength) return
182
- else if (newLength > currentLength) {
190
+ if (newLength === currentLength) {
191
+ return
192
+ } else if (newLength > currentLength) {
183
193
  const newItems = new Array(newLength - currentLength)
184
- for (let i = 0; i < newLength - currentLength; i++) newItems[i] = undefined // No Array.fill everywhere...
194
+ for (let i = 0; i < newLength - currentLength; i++) {
195
+ newItems[i] = undefined
196
+ } // No Array.fill everywhere...
185
197
  this.spliceWithArray_(currentLength, 0, newItems)
186
- } else this.spliceWithArray_(newLength, currentLength - newLength)
198
+ } else {
199
+ this.spliceWithArray_(newLength, currentLength - newLength)
200
+ }
187
201
  }
188
202
 
189
203
  updateArrayLength_(oldLength: number, delta: number) {
190
- if (oldLength !== this.lastKnownLength_) die(16)
204
+ if (oldLength !== this.lastKnownLength_) {
205
+ die(16)
206
+ }
191
207
  this.lastKnownLength_ += delta
192
- if (this.legacyMode_ && delta > 0) reserveArrayBuffer(oldLength + delta + 1)
208
+ if (this.legacyMode_ && delta > 0) {
209
+ reserveArrayBuffer(oldLength + delta + 1)
210
+ }
193
211
  }
194
212
 
195
213
  spliceWithArray_(index: number, deleteCount?: number, newItems?: any[]): any[] {
196
214
  checkIfStateModificationsAreAllowed(this.atom_)
197
215
  const length = this.values_.length
198
216
 
199
- if (index === undefined) index = 0
200
- else if (index > length) index = length
201
- else if (index < 0) index = Math.max(0, length + index)
217
+ if (index === undefined) {
218
+ index = 0
219
+ } else if (index > length) {
220
+ index = length
221
+ } else if (index < 0) {
222
+ index = Math.max(0, length + index)
223
+ }
202
224
 
203
- if (arguments.length === 1) deleteCount = length - index
204
- else if (deleteCount === undefined || deleteCount === null) deleteCount = 0
205
- else deleteCount = Math.max(0, Math.min(deleteCount, length - index))
225
+ if (arguments.length === 1) {
226
+ deleteCount = length - index
227
+ } else if (deleteCount === undefined || deleteCount === null) {
228
+ deleteCount = 0
229
+ } else {
230
+ deleteCount = Math.max(0, Math.min(deleteCount, length - index))
231
+ }
206
232
 
207
- if (newItems === undefined) newItems = EMPTY_ARRAY
233
+ if (newItems === undefined) {
234
+ newItems = EMPTY_ARRAY
235
+ }
208
236
 
209
237
  if (hasInterceptors(this)) {
210
238
  const change = interceptChange<IArrayWillSplice<any>>(this as any, {
@@ -214,7 +242,9 @@ export class ObservableArrayAdministration
214
242
  removedCount: deleteCount,
215
243
  added: newItems
216
244
  })
217
- if (!change) return EMPTY_ARRAY
245
+ if (!change) {
246
+ return EMPTY_ARRAY
247
+ }
218
248
  deleteCount = change.removedCount
219
249
  newItems = change.added
220
250
  }
@@ -227,8 +257,9 @@ export class ObservableArrayAdministration
227
257
  }
228
258
  const res = this.spliceItemsIntoValues_(index, deleteCount, newItems)
229
259
 
230
- if (deleteCount !== 0 || newItems.length !== 0)
260
+ if (deleteCount !== 0 || newItems.length !== 0) {
231
261
  this.notifyArraySplice_(index, newItems, res)
262
+ }
232
263
  return this.dehanceValues_(res)
233
264
  }
234
265
 
@@ -242,9 +273,12 @@ export class ObservableArrayAdministration
242
273
  let oldItems = this.values_.slice(index + deleteCount)
243
274
  // New length is the previous length + addition count - deletion count
244
275
  this.values_.length += newItems.length - deleteCount
245
- for (let i = 0; i < newItems.length; i++) this.values_[index + i] = newItems[i]
246
- for (let i = 0; i < oldItems.length; i++)
276
+ for (let i = 0; i < newItems.length; i++) {
277
+ this.values_[index + i] = newItems[i]
278
+ }
279
+ for (let i = 0; i < oldItems.length; i++) {
247
280
  this.values_[index + newItems.length + i] = oldItems[i]
281
+ }
248
282
  return res
249
283
  }
250
284
  }
@@ -267,10 +301,16 @@ export class ObservableArrayAdministration
267
301
 
268
302
  // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
269
303
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
270
- if (__DEV__ && notifySpy) spyReportStart(change!)
304
+ if (__DEV__ && notifySpy) {
305
+ spyReportStart(change!)
306
+ }
271
307
  this.atom_.reportChanged()
272
- if (notify) notifyListeners(this, change)
273
- if (__DEV__ && notifySpy) spyReportEnd()
308
+ if (notify) {
309
+ notifyListeners(this, change)
310
+ }
311
+ if (__DEV__ && notifySpy) {
312
+ spyReportEnd()
313
+ }
274
314
  }
275
315
 
276
316
  notifyArraySplice_(index: number, added: any[], removed: any[]) {
@@ -291,11 +331,17 @@ export class ObservableArrayAdministration
291
331
  } as const)
292
332
  : null
293
333
 
294
- if (__DEV__ && notifySpy) spyReportStart(change!)
334
+ if (__DEV__ && notifySpy) {
335
+ spyReportStart(change!)
336
+ }
295
337
  this.atom_.reportChanged()
296
338
  // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
297
- if (notify) notifyListeners(this, change)
298
- if (__DEV__ && notifySpy) spyReportEnd()
339
+ if (notify) {
340
+ notifyListeners(this, change)
341
+ }
342
+ if (__DEV__ && notifySpy) {
343
+ spyReportEnd()
344
+ }
299
345
  }
300
346
 
301
347
  get_(index: number): any | undefined {
@@ -323,7 +369,9 @@ export class ObservableArrayAdministration
323
369
  index,
324
370
  newValue
325
371
  })
326
- if (!change) return
372
+ if (!change) {
373
+ return
374
+ }
327
375
  newValue = change.newValue
328
376
  }
329
377
  newValue = this.enhancer_(newValue, oldValue)
@@ -34,7 +34,8 @@ import {
34
34
  isFunction,
35
35
  UPDATE,
36
36
  IAtom,
37
- PureSpyEvent
37
+ PureSpyEvent,
38
+ allowStateChanges
38
39
  } from "../internal"
39
40
 
40
41
  export interface IKeyValueMap<V = any> {
@@ -107,7 +108,9 @@ export class ObservableMap<K = any, V = any>
107
108
  this.keysAtom_ = createAtom(__DEV__ ? `${this.name_}.keys()` : "ObservableMap.keys()")
108
109
  this.data_ = new Map()
109
110
  this.hasMap_ = new Map()
110
- this.merge(initialData)
111
+ allowStateChanges(true, () => {
112
+ this.merge(initialData)
113
+ })
111
114
  }
112
115
 
113
116
  private has_(key: K): boolean {
@@ -115,7 +118,9 @@ export class ObservableMap<K = any, V = any>
115
118
  }
116
119
 
117
120
  has(key: K): boolean {
118
- if (!globalState.trackingDerivation) return this.has_(key)
121
+ if (!globalState.trackingDerivation) {
122
+ return this.has_(key)
123
+ }
119
124
 
120
125
  let entry = this.hasMap_.get(key)
121
126
  if (!entry) {
@@ -141,7 +146,9 @@ export class ObservableMap<K = any, V = any>
141
146
  newValue: value,
142
147
  name: key
143
148
  })
144
- if (!change) return this
149
+ if (!change) {
150
+ return this
151
+ }
145
152
  value = change.newValue!
146
153
  }
147
154
  if (hasKey) {
@@ -160,7 +167,9 @@ export class ObservableMap<K = any, V = any>
160
167
  object: this,
161
168
  name: key
162
169
  })
163
- if (!change) return false
170
+ if (!change) {
171
+ return false
172
+ }
164
173
  }
165
174
  if (this.has_(key)) {
166
175
  const notifySpy = isSpyEnabled()
@@ -177,7 +186,9 @@ export class ObservableMap<K = any, V = any>
177
186
  }
178
187
  : null
179
188
 
180
- if (__DEV__ && notifySpy) spyReportStart(change! as PureSpyEvent) // TODO fix type
189
+ if (__DEV__ && notifySpy) {
190
+ spyReportStart(change! as PureSpyEvent)
191
+ } // TODO fix type
181
192
  transaction(() => {
182
193
  this.keysAtom_.reportChanged()
183
194
  this.hasMap_.get(key)?.setNewValue_(false)
@@ -185,8 +196,12 @@ export class ObservableMap<K = any, V = any>
185
196
  observable.setNewValue_(undefined as any)
186
197
  this.data_.delete(key)
187
198
  })
188
- if (notify) notifyListeners(this, change)
189
- if (__DEV__ && notifySpy) spyReportEnd()
199
+ if (notify) {
200
+ notifyListeners(this, change)
201
+ }
202
+ if (__DEV__ && notifySpy) {
203
+ spyReportEnd()
204
+ }
190
205
  return true
191
206
  }
192
207
  return false
@@ -210,10 +225,16 @@ export class ObservableMap<K = any, V = any>
210
225
  newValue
211
226
  }
212
227
  : null
213
- if (__DEV__ && notifySpy) spyReportStart(change! as PureSpyEvent) // TODO fix type
228
+ if (__DEV__ && notifySpy) {
229
+ spyReportStart(change! as PureSpyEvent)
230
+ } // TODO fix type
214
231
  observable.setNewValue_(newValue as V)
215
- if (notify) notifyListeners(this, change)
216
- if (__DEV__ && notifySpy) spyReportEnd()
232
+ if (notify) {
233
+ notifyListeners(this, change)
234
+ }
235
+ if (__DEV__ && notifySpy) {
236
+ spyReportEnd()
237
+ }
217
238
  }
218
239
  }
219
240
 
@@ -244,13 +265,21 @@ export class ObservableMap<K = any, V = any>
244
265
  newValue
245
266
  }
246
267
  : null
247
- if (__DEV__ && notifySpy) spyReportStart(change! as PureSpyEvent) // TODO fix type
248
- if (notify) notifyListeners(this, change)
249
- if (__DEV__ && notifySpy) spyReportEnd()
268
+ if (__DEV__ && notifySpy) {
269
+ spyReportStart(change! as PureSpyEvent)
270
+ } // TODO fix type
271
+ if (notify) {
272
+ notifyListeners(this, change)
273
+ }
274
+ if (__DEV__ && notifySpy) {
275
+ spyReportEnd()
276
+ }
250
277
  }
251
278
 
252
279
  get(key: K): V | undefined {
253
- if (this.has(key)) return this.dehanceValue_(this.data_.get(key)!.get())
280
+ if (this.has(key)) {
281
+ return this.dehanceValue_(this.data_.get(key)!.get())
282
+ }
254
283
  return this.dehanceValue_(undefined)
255
284
  }
256
285
 
@@ -299,24 +328,31 @@ export class ObservableMap<K = any, V = any>
299
328
  }
300
329
 
301
330
  forEach(callback: (value: V, key: K, object: Map<K, V>) => void, thisArg?) {
302
- for (const [key, value] of this) callback.call(thisArg, value, key, this)
331
+ for (const [key, value] of this) {
332
+ callback.call(thisArg, value, key, this)
333
+ }
303
334
  }
304
335
 
305
336
  /** Merge another object into this object, returns this. */
306
- merge(other: ObservableMap<K, V> | IKeyValueMap<V> | any): ObservableMap<K, V> {
337
+ merge(other?: IObservableMapInitialValues<K, V>): ObservableMap<K, V> {
307
338
  if (isObservableMap(other)) {
308
339
  other = new Map(other)
309
340
  }
310
341
  transaction(() => {
311
- if (isPlainObject(other))
342
+ if (isPlainObject(other)) {
312
343
  getPlainObjectKeys(other).forEach((key: any) =>
313
- this.set(key as any as K, other[key])
344
+ this.set(key as K, (other as IKeyValueMap)[key])
314
345
  )
315
- else if (Array.isArray(other)) other.forEach(([key, value]) => this.set(key, value))
316
- else if (isES6Map(other)) {
317
- if (other.constructor !== Map) die(19, other)
346
+ } else if (Array.isArray(other)) {
347
+ other.forEach(([key, value]) => this.set(key, value))
348
+ } else if (isES6Map(other)) {
349
+ if (other.constructor !== Map) {
350
+ die(19, other)
351
+ }
318
352
  other.forEach((value, key) => this.set(key, value))
319
- } else if (other !== null && other !== undefined) die(20, other)
353
+ } else if (other !== null && other !== undefined) {
354
+ die(20, other)
355
+ }
320
356
  })
321
357
  return this
322
358
  }
@@ -324,12 +360,14 @@ export class ObservableMap<K = any, V = any>
324
360
  clear() {
325
361
  transaction(() => {
326
362
  untracked(() => {
327
- for (const key of this.keys()) this.delete(key)
363
+ for (const key of this.keys()) {
364
+ this.delete(key)
365
+ }
328
366
  })
329
367
  })
330
368
  }
331
369
 
332
- replace(values: ObservableMap<K, V> | IKeyValueMap<V> | any): ObservableMap<K, V> {
370
+ replace(values: IObservableMapInitialValues<K, V>): ObservableMap<K, V> {
333
371
  // Implementation requirements:
334
372
  // - respect ordering of replacement map
335
373
  // - allow interceptors to run and potentially prevent individual operations
@@ -430,8 +468,9 @@ export class ObservableMap<K = any, V = any>
430
468
  * for callback details
431
469
  */
432
470
  observe_(listener: (changes: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda {
433
- if (__DEV__ && fireImmediately === true)
471
+ if (__DEV__ && fireImmediately === true) {
434
472
  die("`observe` doesn't support fireImmediately=true in combination with maps.")
473
+ }
435
474
  return registerListener(this, listener)
436
475
  }
437
476
 
@@ -136,7 +136,9 @@ export class ObservableObjectAdministration
136
136
  name: key,
137
137
  newValue
138
138
  })
139
- if (!change) return null
139
+ if (!change) {
140
+ return null
141
+ }
140
142
  newValue = (change as any).newValue
141
143
  }
142
144
  newValue = (observable as any).prepareNewValue_(newValue)
@@ -158,10 +160,16 @@ export class ObservableObjectAdministration
158
160
  }
159
161
  : null
160
162
 
161
- if (__DEV__ && notifySpy) spyReportStart(change!)
163
+ if (__DEV__ && notifySpy) {
164
+ spyReportStart(change!)
165
+ }
162
166
  ;(observable as ObservableValue<any>).setNewValue_(newValue)
163
- if (notify) notifyListeners(this, change)
164
- if (__DEV__ && notifySpy) spyReportEnd()
167
+ if (notify) {
168
+ notifyListeners(this, change)
169
+ }
170
+ if (__DEV__ && notifySpy) {
171
+ spyReportEnd()
172
+ }
165
173
  }
166
174
  return true
167
175
  }
@@ -256,8 +264,12 @@ export class ObservableObjectAdministration
256
264
  const descriptor = getDescriptor(source, key)
257
265
  if (descriptor) {
258
266
  const outcome = annotation.make_(this, key, descriptor, source)
259
- if (outcome === MakeResult.Cancel) return
260
- if (outcome === MakeResult.Break) break
267
+ if (outcome === MakeResult.Cancel) {
268
+ return
269
+ }
270
+ if (outcome === MakeResult.Break) {
271
+ break
272
+ }
261
273
  }
262
274
  source = Object.getPrototypeOf(source)
263
275
  }
@@ -320,7 +332,9 @@ export class ObservableObjectAdministration
320
332
  type: ADD,
321
333
  newValue: descriptor.value
322
334
  })
323
- if (!change) return null
335
+ if (!change) {
336
+ return null
337
+ }
324
338
  const { newValue } = change as any
325
339
  if (descriptor.value !== newValue) {
326
340
  descriptor = {
@@ -372,7 +386,9 @@ export class ObservableObjectAdministration
372
386
  type: ADD,
373
387
  newValue: value
374
388
  })
375
- if (!change) return null
389
+ if (!change) {
390
+ return null
391
+ }
376
392
  value = (change as any).newValue
377
393
  }
378
394
 
@@ -434,7 +450,9 @@ export class ObservableObjectAdministration
434
450
  type: ADD,
435
451
  newValue: undefined
436
452
  })
437
- if (!change) return null
453
+ if (!change) {
454
+ return null
455
+ }
438
456
  }
439
457
  options.name ||= __DEV__ ? `${this.name_}.${key.toString()}` : "ObservableObject.key"
440
458
  options.context = this.proxy_ || this.target_
@@ -485,7 +503,9 @@ export class ObservableObjectAdministration
485
503
  type: REMOVE
486
504
  })
487
505
  // Cancelled
488
- if (!change) return null
506
+ if (!change) {
507
+ return null
508
+ }
489
509
  }
490
510
 
491
511
  // Delete
@@ -539,9 +559,15 @@ export class ObservableObjectAdministration
539
559
  oldValue: value,
540
560
  name: key
541
561
  }
542
- if (__DEV__ && notifySpy) spyReportStart(change!)
543
- if (notify) notifyListeners(this, change)
544
- if (__DEV__ && notifySpy) spyReportEnd()
562
+ if (__DEV__ && notifySpy) {
563
+ spyReportStart(change!)
564
+ }
565
+ if (notify) {
566
+ notifyListeners(this, change)
567
+ }
568
+ if (__DEV__ && notifySpy) {
569
+ spyReportEnd()
570
+ }
545
571
  }
546
572
  } finally {
547
573
  endBatch()
@@ -555,8 +581,9 @@ export class ObservableObjectAdministration
555
581
  * for callback details
556
582
  */
557
583
  observe_(callback: (changes: IObjectDidChange) => void, fireImmediately?: boolean): Lambda {
558
- if (__DEV__ && fireImmediately === true)
584
+ if (__DEV__ && fireImmediately === true) {
559
585
  die("`observe` doesn't support the fire immediately property for observable objects.")
586
+ }
560
587
  return registerListener(this, callback)
561
588
  }
562
589
 
@@ -580,9 +607,15 @@ export class ObservableObjectAdministration
580
607
  } as const)
581
608
  : null
582
609
 
583
- if (__DEV__ && notifySpy) spyReportStart(change!)
584
- if (notify) notifyListeners(this, change)
585
- if (__DEV__ && notifySpy) spyReportEnd()
610
+ if (__DEV__ && notifySpy) {
611
+ spyReportStart(change!)
612
+ }
613
+ if (notify) {
614
+ notifyListeners(this, change)
615
+ }
616
+ if (__DEV__ && notifySpy) {
617
+ spyReportEnd()
618
+ }
586
619
  }
587
620
 
588
621
  this.pendingKeys_?.get(key)?.set(true)
@@ -631,8 +664,9 @@ export function asObservableObject(
631
664
  return target
632
665
  }
633
666
 
634
- if (__DEV__ && !Object.isExtensible(target))
667
+ if (__DEV__ && !Object.isExtensible(target)) {
635
668
  die("Cannot make the designated object observable; it is not extensible")
669
+ }
636
670
 
637
671
  const name =
638
672
  options?.name ??