vue APIs
- createApp
- ref
- App
- Ref
- VNode
- defineComponent
- reactive
- watch
- computed
- onMounted
- inject
- onUnmounted
- h
- InjectionKey
- getCurrentInstance
- ComputedRef
- PropType
- Component
- nextTick
- watchEffect
- provide
- ComponentPublicInstance
- ComponentInternalInstance
- DirectiveBinding
- toRefs
- toRaw
- VueConstructor
- markRaw
- Plugin
- isRef
- onBeforeMount
- onBeforeUnmount
- readonly
- unref
- UnwrapRef
- createVNode
- shallowRef
- createSSRApp
- WatchStopHandle
- shallowReactive
- CSSProperties
- DeepReadonly
- toRef
- ExtractPropTypes
- WritableComputedRef
- render
- customRef
- ObjectDirective
- Directive
- CreateElement
- DefineComponent
- defineAsyncComponent
- ConcreteComponent
- effectScope
- EffectScope
- ComponentOptions
- SetupContext
- VueElement
- resolveComponent
- capitalize
- defineCustomElement
- triggerRef
- ComponentPropsOptions
- isVNode
- WatchOptions
- useCssModule
- Slots
- isReadonly
- onErrorCaptured
- ComponentObjectPropsOptions
- resolveDirective
- withDirectives
- Text
- queuePostFlushCb
- Fragment
- VNodeArrayChildren
- RenderFunction
- VNodeChild
- DirectiveOptions
- PluginFunction
- isReactive
- isProxy
- ButtonHTMLAttributes
- createTextVNode
- TeleportProps
- onDeactivated
- VNodeNormalizedChildren
Other Related APIs
vue#WritableComputedRef TypeScript Examples
The following examples show how to use
vue#WritableComputedRef.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: use-memo.ts From vooks with MIT License | 6 votes |
function useMemo<T> (
getterOrOptions: MemoGetter<T> | WritableMemoOptions<T>
): ComputedRef<T> | WritableComputedRef<T> {
const computedValueRef = computed(getterOrOptions as any) as
| WritableComputedRef<T>
| ComputedRef<T>
// Maybe it's not possible to lazy evaluate the value, since we can't make
// render phase capture the deps behind useMemo
const valueRef = ref(computedValueRef.value) as Ref<T>
watch(computedValueRef, (value) => {
valueRef.value = value
})
if (typeof getterOrOptions === 'function') {
return valueRef as ComputedRef<T>
} else {
return ({
__v_isRef: true,
get value () {
return valueRef.value
},
set value (v: T) {
(getterOrOptions as WritableMemoOptions<T>).set(v)
}
} as unknown) as WritableComputedRef<T>
}
}