Skip to content

Reactivator API: isRef()

Appurist (Paul) edited this page Sep 17, 2020 · 1 revision

isRef()

Parameters: (obj)

Returns: true if the specified argument (obj) was previously returned by ref()

This boolean method can be used to check if an object is a reactivator ref.

Example usage:

import { ref, isRef, isReactive } from 'reactivator'

const COUNT = 42
let count = ref(COUNT)

console.log("isRef(COUNT) is",isRef(COUNT));
console.log("isRef(count) is",isRef(count));
console.log("isReactive(count) is",isReactive(count)); 

Resulting output:

isRef(COUNT) is false
isRef(count) is true
isReactive(count) is false