2019-06-07 06:55:38 +00:00
|
|
|
export {
|
2019-08-16 14:02:53 +00:00
|
|
|
ref,
|
|
|
|
isRef,
|
2019-08-20 13:38:00 +00:00
|
|
|
toRefs,
|
2019-08-16 14:02:53 +00:00
|
|
|
reactive,
|
|
|
|
isReactive,
|
2019-08-23 13:38:32 +00:00
|
|
|
readonly,
|
|
|
|
isReadonly,
|
2019-06-11 15:50:28 +00:00
|
|
|
toRaw,
|
2019-08-23 13:38:32 +00:00
|
|
|
markReadonly,
|
2019-06-07 06:55:38 +00:00
|
|
|
markNonReactive,
|
|
|
|
effect,
|
|
|
|
// types
|
|
|
|
ReactiveEffect,
|
|
|
|
ReactiveEffectOptions,
|
|
|
|
DebuggerEvent,
|
|
|
|
OperationTypes,
|
2019-08-16 14:02:53 +00:00
|
|
|
Ref,
|
|
|
|
ComputedRef,
|
2019-09-04 02:25:38 +00:00
|
|
|
UnwrapRef,
|
2019-09-05 22:48:49 +00:00
|
|
|
WritableComputedOptions
|
2019-06-11 15:50:28 +00:00
|
|
|
} from '@vue/reactivity'
|
2019-06-07 06:55:38 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
computed as _computed,
|
2019-08-16 14:02:53 +00:00
|
|
|
ComputedRef,
|
2019-09-05 22:48:49 +00:00
|
|
|
WritableComputedOptions,
|
2019-10-10 18:08:12 +00:00
|
|
|
ReactiveEffect,
|
|
|
|
WritableComputedRef
|
2019-06-11 15:50:28 +00:00
|
|
|
} from '@vue/reactivity'
|
2019-06-07 06:55:38 +00:00
|
|
|
|
|
|
|
import { currentInstance } from './component'
|
|
|
|
|
|
|
|
// record effects created during a component's setup() so that they can be
|
|
|
|
// stopped when the component unmounts
|
|
|
|
export function recordEffect(effect: ReactiveEffect) {
|
|
|
|
if (currentInstance) {
|
|
|
|
;(currentInstance.effects || (currentInstance.effects = [])).push(effect)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:01:05 +00:00
|
|
|
export function computed<T>(getter: () => T): ComputedRef<T>
|
2019-10-10 18:08:12 +00:00
|
|
|
export function computed<T>(
|
|
|
|
options: WritableComputedOptions<T>
|
|
|
|
): WritableComputedRef<T>
|
|
|
|
export function computed<T>(
|
|
|
|
getterOrOptions: (() => T) | WritableComputedOptions<T>
|
|
|
|
) {
|
|
|
|
const c = _computed(getterOrOptions as any)
|
2019-06-07 06:55:38 +00:00
|
|
|
recordEffect(c.effect)
|
|
|
|
return c
|
|
|
|
}
|