Repository URL to install this package:
Version:
2.0.4 ▾
|
import { isObservableObj } from './isObservableObj'
import { isObservableArray } from './isObservableArray'
import { ObservableObjectAdministration } from '../typings'
import { toMobxSymbol, createPredicateForProperty } from '../deps'
import { isAtom } from './isAtom'
import { isReaction } from './isReaction'
// import { isComputedValue } from './isComputed'
export function isObservable(value, property?: string): boolean {
if (value === null || value === undefined) return false
if (property !== undefined) {
if (isObservableObj(value)) {
const $mobx = toMobxSymbol(value) as any
return (<ObservableObjectAdministration>(value as any)[$mobx]).values.has(
property
)
}
return false
}
// For first check, see #701
return (
isObservableObj(value) ||
!!value[toMobxSymbol(value) as any] ||
isAtom(value) ||
isReaction(value)
// isComputedValue(value)
)
}