Files
directus/app/src/composables/use-sync
2021-05-04 18:52:08 -04:00
..
2020-07-29 11:24:52 -04:00
2021-05-04 18:52:08 -04:00
2020-11-11 15:05:53 -05:00

Use Sync

function useSync<T, K extends keyof T>(
	props: T,
	key: K,

	emit: (event: string, ...args: any[]) => void
): Ref<Readonly<T[K]>>;

Small utility composition that allows you to easily setup the two-way binding with the prop:

// Before

const _options = computed({
	get() {
		return props.options;
	},
	set(val) {
		emit('update:options', val);
	},
});
// after

const _options = useSync(props, 'options', emit);