import { WatchOptions } from 'vue' ; import { createDecorator } from 'vue-class-component' ; param path param watchOptions export function Watch ( path , watchOptions = { } ) { return createDecorator ( ( componentOptions , handler ) => { componentOptions . watch ||= Object . create ( null ) ; const watch = componentOptions . watch ; if ( typeof watch [ path ] === 'object' && ! Array . isArray ( watch [ path ] ) ) { watch [ path ] = [ watch [ path ] ] ; } else if ( typeof watch [ path ] === 'undefined' ) { watch [ path ] = [ ] ; } watch [ path ] . push ( { handler , ... watchOptions } ) ; } ) ; }