Add signal API Design to reactivity #747
teleskop150750
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Untrack
When used inside a watchEffect or computed, any state read inside fn will not be treated as a dependency.
Like solid, svelte, preact, angular
Signal
It would be very useful to see a signals API similar to the implementation in solid.
Or implement explicit methods for inserting and getting the value
const [count, setCount] = createSignal(0)
The Problem
Readonly signal
Many libraries were forced to use
readonly()
, which hurts performance, or find other ways. Explicitly separating getters and setters fixes this complexity.Example: TanStack query discussions
More flexible signal update
When updating a signal based on its previous value, the code for getting it is called first, then the new value is set. In this case, the signal is added to the effect's dependency list.
Better Dx for writing composables
Often, passing and updating reactive variables in composables requires additionally wrapping them in functions.
If such methods were initially available, this would not be necessary
Simplifying MaybeRefOrGetter
Currently, it is a popular practice to process 3 different parameters: Ref, Function, non-ref variable.
For this, the helpers
type MaybeRefOrGetter
andtoValue
have been added.Example vueuse
Thanks to the signals API, we have two types of data for options in composable objects.
a new api could popularize this method
Beta Was this translation helpful? Give feedback.
All reactions