MCPcopy
hub / github.com/vuejs/composition-api / createRef

Function createRef

src/reactivity/ref.ts:76–94  ·  view source on GitHub ↗
(
  options: RefOption<T>,
  isReadonly = false,
  isComputed = false
)

Source from the content-addressed store, hash-verified

74}
75
76export function createRef<T>(
77 options: RefOption<T>,
78 isReadonly = false,
79 isComputed = false
80): RefImpl<T> {
81 const r = new RefImpl<T>(options)
82
83 // add effect to differentiate refs from computed
84 if (isComputed) (r as ComputedRef<T>).effect = true
85
86 // seal the ref, this could prevent ref from being observed
87 // It's safe to seal the ref, since we really shouldn't extend it.
88 // related issues: #79
89 const sealed = Object.seal(r)
90
91 if (isReadonly) readonlySet.set(sealed, true)
92
93 return sealed
94}
95
96export function ref<T extends object>(
97 raw: T

Callers 5

computedFunction · 0.90
refFunction · 0.85
customRefFunction · 0.85
toRefFunction · 0.85
shallowRefFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…