2019-06-07 14:55:38 +08:00
|
|
|
export {
|
2019-08-16 22:02:53 +08:00
|
|
|
ref,
|
|
|
|
isRef,
|
2019-08-20 21:38:00 +08:00
|
|
|
toRefs,
|
2019-08-16 22:02:53 +08:00
|
|
|
reactive,
|
|
|
|
isReactive,
|
2019-08-23 21:38:32 +08:00
|
|
|
readonly,
|
|
|
|
isReadonly,
|
2019-06-11 23:50:28 +08:00
|
|
|
toRaw,
|
2019-08-23 21:38:32 +08:00
|
|
|
markReadonly,
|
2019-06-07 14:55:38 +08:00
|
|
|
markNonReactive,
|
|
|
|
effect,
|
|
|
|
// types
|
|
|
|
ReactiveEffect,
|
|
|
|
ReactiveEffectOptions,
|
|
|
|
DebuggerEvent,
|
|
|
|
OperationTypes,
|
2019-08-16 22:02:53 +08:00
|
|
|
Ref,
|
|
|
|
ComputedRef,
|
2019-09-04 10:25:38 +08:00
|
|
|
UnwrapRef,
|
|
|
|
ComputedOptions
|
2019-06-11 23:50:28 +08:00
|
|
|
} from '@vue/reactivity'
|
2019-06-07 14:55:38 +08:00
|
|
|
|
|
|
|
import {
|
2019-08-22 00:01:05 +08:00
|
|
|
Ref,
|
2019-06-07 14:55:38 +08:00
|
|
|
computed as _computed,
|
2019-08-16 22:02:53 +08:00
|
|
|
ComputedRef,
|
2019-08-20 21:45:28 +08:00
|
|
|
ComputedOptions,
|
2019-06-07 14:55:38 +08:00
|
|
|
ReactiveEffect
|
2019-06-11 23:50:28 +08:00
|
|
|
} from '@vue/reactivity'
|
2019-06-07 14:55:38 +08: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-22 00:01:05 +08:00
|
|
|
export function computed<T>(getter: () => T): ComputedRef<T>
|
|
|
|
export function computed<T>(options: ComputedOptions<T>): Ref<T>
|
|
|
|
export function computed<T>(getterOrOptions: any) {
|
2019-08-20 21:45:28 +08:00
|
|
|
const c = _computed(getterOrOptions)
|
2019-06-07 14:55:38 +08:00
|
|
|
recordEffect(c.effect)
|
|
|
|
return c
|
|
|
|
}
|