import { copy } from '@/utils/shared'
import { Ref, ref, watch } from 'vue'

export const useAutomaticData = <T>(
	getter: () => T,
	acopy = copy
) => {
	const data = ref() as Ref<T>
	watch(getter, (newData) => {
		data.value = acopy(newData)
	}, { immediate: true, deep: true })
	return data;
}