V Dollar Save

jQuery-like Vue Reactivity API

Project README

v-dollar

jQuery-like Vue Reactivity API , it's well-typed!

npm i v-dollar

ref => $
computed => $
watch => $
unref => $
set => $

You are welcome.

Usages

with v-dollar

import { $ } from 'v-dollar'

const counter = $(0)
const doubled = $(() => $(counter) * 2)

const reset = () => $(counter, 0)
const double = () => $(counter, doubled)

$(counter, (value) => console.log(value), { flush: 'post' })

w/o v-dollar

import { ref, computed, unref, watch } from 'vue'

const counter = ref(0)
const doubled = computed(() => counter.value * 2)

const reset = () => counter.value = 0
const double = () => counter.value = unref(doubled)

watch(counter, (value) => console.log(value), { flush: 'post' })

Or if you prefer this 😈:

import { $ as _ } from 'v-dollar'

const counter = _(0)
const doubled = _(() => _(counter) * 2)

const reset = () => _(counter, 0)
const double = () => _(counter, doubled)

_(counter, (value) => console.log(value), { flush: 'post' })

Why?

FUN.

Don't take it seriously, it's just a toy. But yeah, you can use it in prod if you like, we have nearly 100% test coverage :p

License

MIT

Open Source Agenda is not affiliated with "V Dollar" Project. README Source: antfu/v-dollar
Stars
163
Open Issues
0
Last Commit
3 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating