MCPcopy
hub / github.com/mobxjs/mobx / initObservable

Function initObservable

packages/mobx/src/types/type-utils.ts:108–119  ·  view source on GitHub ↗
(cb: () => T)

Source from the content-addressed store, hash-verified

106 * 3. batch to avoid state version updates
107 */
108export function initObservable<T>(cb: () => T): T {
109 const derivation = untrackedStart()
110 const allowStateChanges = allowStateChangesStart(true)
111 startBatch()
112 try {
113 return cb()
114 } finally {
115 endBatch()
116 allowStateChangesEnd(allowStateChanges)
117 untrackedEnd(derivation)
118 }
119}

Callers 7

constructorMethod · 0.85
constructorMethod · 0.85
createObservableArrayFunction · 0.85
constructorMethod · 0.85
extendObservableFunction · 0.85
makeObservableFunction · 0.85
makeAutoObservableFunction · 0.85

Calls 6

untrackedStartFunction · 0.85
allowStateChangesStartFunction · 0.85
startBatchFunction · 0.85
endBatchFunction · 0.85
allowStateChangesEndFunction · 0.85
untrackedEndFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…