-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(reactivity): new function toShallowRef
#8530
base: minor
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
9581209
to
d869358
Compare
19ba4d3
to
06723cc
Compare
It isn't clear to me that this should be using There's an alternative implementation of |
fecf23b
to
1caa569
Compare
@skirtles-code The contentious part is currently being handled in a manner similar to |
This implementation lacks following signatures: export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>; Added on comment on RFC, and mentioning here as well, this API should allow all usages of Ability to do |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
The
toShallowRef
function is used to convert a given value into a shallow reference.The function accepts various types of values as input, including functions,
Ref
objects, and regular values. Depending on the type of the input value, the function performs the appropriate conversion:Readonly<Ref<T>>
object, which represents a read-only reference to the value returned by the function.Ref
object, it is converted into aRef<T>
object, preserving its reactivity.ShallowRef<T>
object, which provides shallow reactivity to the value.By using
toShallowRef
, developers can easily create shallow reference objects that can be used in reactive contexts, such as Vue.js components, to automatically update relevant views when the value changes.example:
RFC