11import { isServerRendering , noop , warn , def , isFunction } from 'core/util'
22import { Ref , RefFlag } from './ref'
33import Watcher from 'core/observer/watcher'
4- import Dep from 'core/observer/dep'
4+ import Dep , { DebuggerOptions } from 'core/observer/dep'
55import { currentInstance } from '../currentInstance'
6- import { DebuggerOptions } from '../apiWatch'
76import { ReactiveFlags } from './reactive'
7+ import { TrackOpTypes } from './operations'
88
99declare const ComputedRefSymbol : unique symbol
1010
@@ -35,7 +35,6 @@ export function computed<T>(
3535) : WritableComputedRef < T >
3636export function computed < T > (
3737 getterOrOptions : ComputedGetter < T > | WritableComputedOptions < T > ,
38- // TODO debug options
3938 debugOptions ?: DebuggerOptions
4039) {
4140 let getter : ComputedGetter < T >
@@ -58,6 +57,11 @@ export function computed<T>(
5857 ? null
5958 : new Watcher ( currentInstance , getter , noop , { lazy : true } )
6059
60+ if ( __DEV__ && watcher && debugOptions ) {
61+ watcher . onTrack = debugOptions . onTrack
62+ watcher . onTrigger = debugOptions . onTrigger
63+ }
64+
6165 const ref = {
6266 // some libs rely on the presence effect for checking computed refs
6367 // from normal refs, but the implementation doesn't matter
@@ -68,6 +72,14 @@ export function computed<T>(
6872 watcher . evaluate ( )
6973 }
7074 if ( Dep . target ) {
75+ if ( __DEV__ && Dep . target . onTrack ) {
76+ Dep . target . onTrack ( {
77+ effect : Dep . target ,
78+ target : ref ,
79+ type : TrackOpTypes . GET ,
80+ key : 'value'
81+ } )
82+ }
7183 watcher . depend ( )
7284 }
7385 return watcher . value
0 commit comments