Files
directus/app/src/utils/sync-ref-property.ts
Oreille ce97a40271 Fix unexpected camera update and unavailable clustering option in map (#9615)
* Fix unexpected camera update and unavailable clustering option in map layout.

* lint warning

* Use defaultSort ref instead of value.

Co-authored-by: Azri Kahar <azrikahar@outlook.com>
2021-11-09 16:03:27 +00:00

13 lines
346 B
TypeScript

import { computed, Ref, unref } from 'vue';
export function syncRefProperty<R, T extends keyof R>(ref: Ref<R>, key: T, defaultValue: R[T] | Ref<R[T]>) {
return computed<R[T]>({
get() {
return ref.value?.[key] ?? unref(defaultValue);
},
set(value: R[T]) {
ref.value = Object.assign({}, ref.value, { [key]: value }) as R;
},
});
}