Vue 3 eager computed that evaluates immediately on dependency change
npm install vue-computed-eager
A Vue 3 composition API utility that creates computed properties which evaluate immediately when dependencies change, rather than lazily on access. Ideal for simple boolean checks with rarely-changing values. Note: Vue 3.4+ has built-in optimization making this less necessary.
``bash`
npm install vue-computed-eager
`ts
import { computedEager } from 'vue-computed-eager'
import { ref } from 'vue'
const todos = ref([])
const hasOpenTodos = computedEager(() => !!todos.value.length)
console.log(hasOpenTodos.value) // false
todos.value.push({ title: 'Learn Vue' })
console.log(hasOpenTodos.value) // true
``
MIT
Extracted from VueUse for standalone use.