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

Method constructor

packages/mobx/src/core/computedvalue.ts:120–140  ·  view source on GitHub ↗

* Create a new computed value based on a function expression. * * The `name` property is for debug purposes only. * * The `equals` property specifies the comparer function to use to determine if a newly produced * value differs from the previous value. Two comparers are prov

(options: IComputedValueOptions<T>)

Source from the content-addressed store, hash-verified

118 * This is useful for working with vectors, mouse coordinates etc.
119 */
120 constructor(options: IComputedValueOptions<T>) {
121 if (!options.get) {
122 die(31)
123 }
124 this.derivation = options.get!
125 this.name_ = options.name || (__DEV__ ? "ComputedValue@" + getNextId() : "ComputedValue")
126 if (options.set) {
127 this.setter_ = createAction(
128 __DEV__ ? this.name_ + "-setter" : "ComputedValue-setter",
129 options.set
130 ) as any
131 }
132 this.equals_ =
133 options.equals ||
134 ((options as any).compareStructural || (options as any).struct
135 ? comparer.structural
136 : comparer.default)
137 this.scope_ = options.context
138 this.requiresReaction_ = options.requiresReaction
139 this.keepAlive_ = !!options.keepAlive
140 }
141
142 onBecomeStale_() {
143 propagateMaybeChanged(this)

Callers

nothing calls this directly

Calls 3

dieFunction · 0.85
createActionFunction · 0.85
getNextIdFunction · 0.50

Tested by

no test coverage detected