Skip to content

antfu/v-dollar

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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