package @vue/reactivity
Interfaces
Name | Summary |
---|---|
This is a special exported interface for other packages to declare additional types that should bail out for ref unwrapping. For example @vue/runtime-dom can declare it like so in its d.ts: ```ts declare module '@vue/reactivity' { export interface RefUnwrapBailTypes { runtimeDOMBailTypes: Node |
|
Window
}
}
|
|
Functions
computed(getter, debugOptions)
Name | Type | Description |
---|---|---|
|
|
|
|
||
Returns |
|
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
computed(options, debugOptions)
Name | Type | Description |
---|---|---|
|
||
|
||
Returns |
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
customRef(factory)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
deferredComputed(getter)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;
effect(fn, options)
Name | Type | Description |
---|---|---|
|
|
|
|
||
Returns |
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
effectScope(detached)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
export declare function effectScope(detached?: boolean): EffectScope;
isProxy(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function isProxy(value: unknown): boolean;
isReactive(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function isReactive(value: unknown): boolean;
isReadonly(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function isReadonly(value: unknown): boolean;
markRaw(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function markRaw<T extends object>(value: T): T;
onScopeDispose(fn)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function onScopeDispose(fn: () => void): void;
proxyRefs(objectWithRefs)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
reactive(target)
Creates a reactive copy of the original object.
The reactive conversion is "deep"—it affects all nested properties. In the ES2015 Proxy based implementation, the returned proxy is *\*not\*\* equal to the original object. It is recommended to work exclusively with the reactive proxy and avoid relying on the original object.
A reactive object also automatically unwraps refs contained in it, so you don’t need to use .value
when accessing and mutating their value:
const count = ref(0)
const obj = reactive({
count
})
obj.count++
obj.count // -> 1
count.value // -> 1
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
readonly(target)
Creates a readonly copy of the original object. Note the returned copy is not made reactive, but readonly
can be called on an already reactive object.
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
ref(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function ref<T extends object>(value: T): ToRef<T>;
ref(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
shallowReactive(target)
Return a shallowly-reactive copy of the original object, where only the root level properties are reactive. It also does not auto-unwrap refs (even at the root level).
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function shallowReactive<T extends object>(target: T): T;
shallowReadonly(target)
Returns a reactive-copy of the original object, where only the root level properties are readonly, and does NOT unwrap refs nor recursively convert returned properties. This is used for creating the props proxy object for stateful components.
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function shallowReadonly<T extends object>(target: T): Readonly<{
[K in keyof T]: UnwrapNestedRefs<T[K]>;
}>;
shallowRef(value)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function shallowRef<T>(value: T): Ref<T>;
stop_2(runner)
Name | Type | Description |
---|---|---|
|
||
Returns |
|
export declare function stop(runner: ReactiveEffectRunner): void;
toRaw(observed)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function toRaw<T>(observed: T): T;
toRef(object, key)
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
Returns |
|
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
toRefs(object)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function toRefs<T extends object>(object: T): ToRefs<T>;
track(target, type, key)
Name | Type | Description |
---|---|---|
|
|
|
|
||
|
|
|
Returns |
|
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
trigger(target, type, key, newValue, oldValue, oldTarget)
Name | Type | Description |
---|---|---|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
Returns |
|
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
triggerRef(ref)
Name | Type | Description |
---|---|---|
|
||
Returns |
|
export declare function triggerRef(ref: Ref): void;
unref(ref)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
export declare function unref<T>(ref: T | Ref<T>): T;