Skip to content

antfu/v-dollar

Repository files navigation

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

About

jQuery-like Vue Reactivity API

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy