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

Function configure

packages/mobx/src/api/configure.ts:8–65  ·  view source on GitHub ↗
(options: {
    enforceActions?: "never" | "always" | "observed"
    computedRequiresReaction?: boolean
    /**
     * Warn if you try to create to derivation / reactive context without accessing any observable.
     */
    reactionRequiresObservable?: boolean
    /**
     * Warn if observables are accessed outside a reactive context
     */
    observableRequiresReaction?: boolean
    isolateGlobalState?: boolean
    disableErrorBoundaries?: boolean
    safeDescriptors?: boolean
    reactionScheduler?: (f: () => void) => void
    useProxies?: "always" | "never" | "ifavailable"
})

Source from the content-addressed store, hash-verified

6// const IF_AVAILABLE = "ifavailable"
7
8export function configure(options: {
9 enforceActions?: "never" | "always" | "observed"
10 computedRequiresReaction?: boolean
11 /**
12 * Warn if you try to create to derivation / reactive context without accessing any observable.
13 */
14 reactionRequiresObservable?: boolean
15 /**
16 * Warn if observables are accessed outside a reactive context
17 */
18 observableRequiresReaction?: boolean
19 isolateGlobalState?: boolean
20 disableErrorBoundaries?: boolean
21 safeDescriptors?: boolean
22 reactionScheduler?: (f: () => void) => void
23 useProxies?: "always" | "never" | "ifavailable"
24}): void {
25 if (options.isolateGlobalState === true) {
26 isolateGlobalState()
27 }
28 const { useProxies, enforceActions } = options
29 if (useProxies !== undefined) {
30 globalState.useProxies =
31 useProxies === ALWAYS
32 ? true
33 : useProxies === NEVER
34 ? false
35 : typeof Proxy !== "undefined"
36 }
37 if (useProxies === "ifavailable") {
38 globalState.verifyProxies = true
39 }
40 if (enforceActions !== undefined) {
41 const ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED
42 globalState.enforceActions = ea
43 globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true
44 }
45 ;[
46 "computedRequiresReaction",
47 "reactionRequiresObservable",
48 "observableRequiresReaction",
49 "disableErrorBoundaries",
50 "safeDescriptors"
51 ].forEach(key => {
52 if (key in options) {
53 globalState[key] = !!options[key]
54 }
55 })
56 globalState.allowStateReads = !globalState.observableRequiresReaction
57 if (__DEV__ && globalState.disableErrorBoundaries === true) {
58 console.warn(
59 "WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."
60 )
61 }
62 if (options.reactionScheduler) {
63 setReactionScheduler(options.reactionScheduler)
64 }
65}

Callers 15

jest.setup.tsFile · 0.90
observerBatchingFunction · 0.90
resetMobxFunction · 0.90
jest.setup.tsFile · 0.90
issue806.test.tsxFile · 0.90
observer.test.tsxFile · 0.90
jest.setup.tsFile · 0.90
map.jsFile · 0.90

Calls 3

isolateGlobalStateFunction · 0.85
setReactionSchedulerFunction · 0.85
forEachMethod · 0.65

Tested by 1

resetMobxFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…