Snapshot của vueuse/vue-chemistry: 414★ · TypeScript · Frontend. Reactified JavaScript functions for Vue
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
The science that deals with the properties, composition, and structure of states, the transformations they undergo during reactions.
Reactified JavaScript functions for Vue, powered by reactify from VueUse.
Reactified? What?
In JavaScript, for most of the time, you are dealing with procedural functions. Which means after the calculation/transformation, the result won't know relationships with its sources, for example
function sum(x, y) {
return x + y
}
let a = 1
const b = 2
const c = sum(a, b) // c = a + b = 3
a = 2
console.log(c) // still 3, not 4
On the other hand, in Spreadsheets apps like Microsoft Excel or Google Sheets, formulas are always up-to-update whenever their source changes.
Vue's reactivity system is a way to approach the reactiveness in JavaScript. In the Composition API, we are kinda mixing the procedural and reactivity together (which is good and flexible). But what it will be like to have a complete reactive developing experience?
Introducing Vue Chemistry, a set of reactified JavaScript functions letting you enjoy the pure reactiveness!
From the example above, now we can have:
import { set } from 'vue-chemistry/core'
import { sum } from 'vue-chemistry/math'
import { log } from 'vue-chemistry/console'
const a = ref(1)
const b = ref(2)
const c = sum(a, b) // c = a + b = 3
set(a, 2) // shorthand for a.value = 2
log(c) // it's 4 (2 + 2)!
Cool, but, how is that possible?
We are basically making functions accepting Ref as their arguments and then wrapper their result with computed. This makes them automatically collect dependency sources and re-evaluate when the sources get changed. Note that the ComputedRef is also a Ref which means the operations are chainable!
An example for comparison:
// procedural function
function sum(x: number, y: number) {
return x + y
}
import type { ComputedRef, Ref } from 'vue'
import { computed, unref } from 'vue'
// reactified function
function sum(
x: number | Ref<number>,
y: number | Ref<number>
): ComputedRef<number> {
return computed(() => unref(x) + unref(y))
}
If you want to convert a normal function into a "reactified" one, you can use reactify() function. The source code can be found here (deadly simple!).
import { reactify } from 'vue-chemistry/core'
function sum(x: number, y: number) {
return x + y
}
const reactifiedSum = reactify(sum)
Install
npm i vue-chemistry
Usage
Functions available in the following namespaces
// see the auto-completion for the full functions list
import { pow, round, sin, sqrt, sum } from 'vue-chemistry/math'
import { toLowerCase, toString } from 'vue-chemistry/string'
import { parseFloat, parseInt } from 'vue-chemistry/number'
import { parse, stringify } from 'vue-chemistry/json'
import { isFalsy } from 'vue-chemistry/boolean'
import { log } from 'vue-chemistry/console'
import { set } from 'vue-chemistry/core'
// or
import * as Math from 'vue-chemistry/math'
Math.sin(a)
Or to have everything in one place:
import { log, parse, parseInt, sqrt } from 'vue-chemistry'
Examples
import { set } from 'vue-chemistry/core'
import { log } from 'vue-chemistry/console'
import { pow, sqrt, sum } from 'vue-chemistry/math'
// Math _________
// c = √ a² + b²
const a = ref(3)
const b = ref(4)
const c = sqrt(sum(pow(a, 2), pow(b, 2)))
log(c) // 5
set(a, 5) // shorthand for a.value = 5
set(b, 12)
log(c) // 13
vueuse/vue-chemistry thuộc nhóm Frontend trên TopGit, cùng 5 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về vueuse/vue-chemistry ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/vueuse/vue-chemistry là nguồn chính thức.
vueuse/vue-chemistry có bao nhiêu sao?
vueuse/vue-chemistry có 414 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/vueuse/vue-chemistry. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
vueuse/vue-chemistry có phải mã nguồn mở không?
Có — vueuse/vue-chemistry phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/vueuse/vue-chemistry.
vueuse/vue-chemistry còn đang phát triển không?
Commit gần nhất trên vueuse/vue-chemistry là 1.1 năm trước (theo timestamp GitHub). Repo có 10 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
vueuse/vue-chemistry dùng license gì?
vueuse/vue-chemistry phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
vueuse/vue-chemistry là gì?
vueuse/vue-chemistry (vueuse/vue-chemistry) là dự án TypeScript trên GitHub. Theo mô tả gốc: Reactified JavaScript functions for Vue
vueuse/vue-chemistry viết bằng ngôn ngữ gì?
vueuse/vue-chemistry chủ yếu viết bằng TypeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc vue-chemistry có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về vue-chemistry.