package @vue/reactivity

Classes

Interfaces

Name Summary

ComputedRef

DebuggerOptions

ReactiveEffectOptions

ReactiveEffectRunner

Ref

RefUnwrapBailTypes

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 } } ` Note that api-extractor somehow refuses to include declare module augmentations in its generated d.ts, so we have to manually append them to the final generated d.ts in our build process.

WritableComputedOptions

WritableComputedRef

Enumerations

Functions

computed(getter, debugOptions)

Parameters
Name Type Description

getter

ComputedGetter<T>

debugOptions

DebuggerOptions

Returns

ComputedRef<T>

Signature
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;

computed(options, debugOptions)

Parameters
Name Type Description

options

WritableComputedOptions<T>

debugOptions

DebuggerOptions

Returns

WritableComputedRef<T>

Signature
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;

customRef(factory)

Parameters
Name Type Description

factory

\~CustomRefFactory<T>

Returns

Ref<T>

Signature
export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;

deferredComputed(getter)

Parameters
Name Type Description

getter

() => T

Returns

ComputedRef<T>

Signature
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;

effect(fn, options)

Parameters
Name Type Description

fn

() => T

options

ReactiveEffectOptions

Returns

ReactiveEffectRunner

Signature
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;

effectScope(detached)

Parameters
Name Type Description

detached

boolean

Returns

EffectScope

Signature
export declare function effectScope(detached?: boolean): EffectScope;

enableTracking()

Signature
export declare function enableTracking(): void;

getCurrentScope()

Signature
export declare function getCurrentScope(): EffectScope | undefined;

isProxy(value)

Parameters
Name Type Description

value

unknown

Returns

boolean

Signature
export declare function isProxy(value: unknown): boolean;

isReactive(value)

Parameters
Name Type Description

value

unknown

Returns

boolean

Signature
export declare function isReactive(value: unknown): boolean;

isReadonly(value)

Parameters
Name Type Description

value

unknown

Returns

boolean

Signature
export declare function isReadonly(value: unknown): boolean;

isRef(r)

Parameters
Name Type Description

r

Ref<T> | unknown

Returns

@vue/reactivity!\~r is Ref<T>

Signature
export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;

markRaw(value)

Parameters
Name Type Description

value

T

Returns

T

Signature
export declare function markRaw<T extends object>(value: T): T;

onScopeDispose(fn)

Parameters
Name Type Description

fn

() => void

Returns

void

Signature
export declare function onScopeDispose(fn: () => void): void;

pauseTracking()

Signature
export declare function pauseTracking(): void;

proxyRefs(objectWithRefs)

Parameters
Name Type Description

objectWithRefs

T

Returns

ShallowUnwrapRef<T>

Signature
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
Parameters
Name Type Description

target

T

Returns

UnwrapNestedRefs<T>

Signature
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.

Parameters
Name Type Description

target

T

Returns

DeepReadonly<UnwrapNestedRefs<T>>

Signature
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;

ref(value)

Parameters
Name Type Description

value

T

Returns

ToRef<T>

Signature
export declare function ref<T extends object>(value: T): ToRef<T>;

ref(value)

Parameters
Name Type Description

value

T

Returns

Ref<UnwrapRef<T>>

Signature
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;

ref()

Signature
export declare function ref<T = any>(): Ref<T | undefined>;

resetTracking()

Signature
export declare function resetTracking(): void;

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).

Parameters
Name Type Description

target

T

Returns

T

Signature
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.

Parameters
Name Type Description

target

T

Returns

Readonly<{ [K in keyof T]: UnwrapNestedRefs<T[K]>; }>

Signature
export declare function shallowReadonly<T extends object>(target: T): Readonly<{
    [K in keyof T]: UnwrapNestedRefs<T[K]>;
}>;

shallowRef(value)

Parameters
Name Type Description

value

T

Returns

T extends Ref ? T : Ref<T>

Signature
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : Ref<T>;

shallowRef(value)

Parameters
Name Type Description

value

T

Returns

Ref<T>

Signature
export declare function shallowRef<T>(value: T): Ref<T>;

shallowRef()

Signature
export declare function shallowRef<T = any>(): Ref<T | undefined>;

stop_2(runner)

Parameters
Name Type Description

runner

ReactiveEffectRunner

Returns

void

Signature
export declare function stop(runner: ReactiveEffectRunner): void;

toRaw(observed)

Parameters
Name Type Description

observed

T

Returns

T

Signature
export declare function toRaw<T>(observed: T): T;

toRef(object, key)

Parameters
Name Type Description

object

T

key

K

Returns

ToRef<T[K]>

Signature
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;

toRefs(object)

Parameters
Name Type Description

object

T

Returns

ToRefs<T>

Signature
export declare function toRefs<T extends object>(object: T): ToRefs<T>;

track(target, type, key)

Parameters
Name Type Description

target

object

type

TrackOpTypes

key

unknown

Returns

void

Signature
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;

trigger(target, type, key, newValue, oldValue, oldTarget)

Parameters
Name Type Description

target

object

type

TriggerOpTypes

key

unknown

newValue

unknown

oldValue

unknown

oldTarget

Map<unknown, unknown> | Set<unknown>

Returns

void

Signature
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;

triggerRef(ref)

Parameters
Name Type Description

ref

Ref

Returns

void

Signature
export declare function triggerRef(ref: Ref): void;

unref(ref)

Parameters
Name Type Description

ref

T | Ref<T>

Returns

T

Signature
export declare function unref<T>(ref: T | Ref<T>): T;