1 | import { $mobx, getAtom, isComputedValue, isObservableObject, die, isStringish } from "../internal"
|
2 |
|
3 | export function _isComputed(value, property?: PropertyKey): boolean {
|
4 | if (property === undefined) {
|
5 | return isComputedValue(value)
|
6 | }
|
7 | if (isObservableObject(value) === false) return false
|
8 | if (!value[$mobx].values_.has(property)) return false
|
9 | const atom = getAtom(value, property)
|
10 | return isComputedValue(atom)
|
11 | }
|
12 |
|
13 | export function isComputed(value: any): boolean {
|
14 | if (__DEV__ && arguments.length > 1)
|
15 | return die(
|
16 | `isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`
|
17 | )
|
18 | return _isComputed(value)
|
19 | }
|
20 |
|
21 | export function isComputedProp(value: any, propName: PropertyKey): boolean {
|
22 | if (__DEV__ && !isStringish(propName))
|
23 | return die(`isComputed expected a property name as second argument`)
|
24 | return _isComputed(value, propName)
|
25 | }
|