getComputedInstance
See source codeRetrieves the underlying computed instance for a given property created with the decorator.
function getComputedInstance<Obj extends object, Prop extends keyof Obj>(
obj: Obj,
propertyName: Prop
): Computed<Obj[Prop]>
Example
class Counter {
max = 100
count = atom(0)
@computed getRemaining() {
return this.max - this.count.get()
}
}
const c = new Counter()
const remaining = getComputedInstance(c, 'getRemaining')
remaining.get() === 100 // true
c.count.set(13)
remaining.get() === 87 // true
Parameters
Name | Description |
---|---|
|
The object |
|
The property name |
Returns
Computed<Obj[Prop]>
Prev
computedNext
isAtom