Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic / src / mobx / is / isObservable.ts
Size: Mime:
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)
  )
}