getComputedInstance
Retrieves the underlying computed instance for a given property created with the computed 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; // trueParameters
| Name | Description |
|---|---|
| The object |
| The property name |
Returns
Computed<Obj[Prop]>;Prev
computedNext
isAtom