getComputedInstance()
Retrieves the underlying computed instance for a given property created with the computed decorator.
Example
class Counter {
max = 100
count = atom(0)
@computed get remaining() {
return this.max - this.count.value
}
}
const c = new Counter()
const remaining = getComputedInstance(c, 'remaining')
remaining.value === 100 // true
c.count.set(13)
remaining.value === 87 // true
Signature
getComputedInstance<Obj, Prop>(obj: Obj, propertyName: Prop): Computed<Obj[Prop]>;
Type parameters
Obj
extendsobject
Prop
extendsstring
|number
|symbol
Parameters
Name | Type |
---|---|
obj | Obj |
propertyName | Prop |
Returns
Computed
<Obj
[Prop
]>
Defined in: signia/src/Computed.ts:278