mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
* move composables, types and utils to shared * move composables, utils and types to shared * expose utils and composables in extensionsSDK * fix missing dependencies * Sort index.ts exports * Do the thing Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
17 lines
329 B
TypeScript
17 lines
329 B
TypeScript
import { computed, Ref } from 'vue';
|
|
|
|
export function useSync<T, K extends keyof T & string, E extends (event: `update:${K}`, ...args: any[]) => void>(
|
|
props: T,
|
|
key: K,
|
|
emit: E
|
|
): Ref<T[K]> {
|
|
return computed<T[K]>({
|
|
get() {
|
|
return props[key];
|
|
},
|
|
set(newVal) {
|
|
emit(`update:${key}` as const, newVal);
|
|
},
|
|
});
|
|
}
|