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>
This commit is contained in:
Oreille
2021-11-09 17:03:27 +01:00
committed by GitHub
parent b1494e8a22
commit ce97a40271
5 changed files with 32 additions and 22 deletions

View File

@@ -1,12 +1,11 @@
import { isFunction } from 'lodash';
import { computed, Ref } from 'vue';
import { computed, Ref, unref } from 'vue';
export function syncRefProperty<R, T extends keyof R>(ref: Ref<R>, key: T, defaultValue: R[T] | (() => R[T])) {
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] ?? (isFunction(defaultValue) ? defaultValue() : defaultValue);
get() {
return ref.value?.[key] ?? unref(defaultValue);
},
set: (value: R[T]) => {
set(value: R[T]) {
ref.value = Object.assign({}, ref.value, { [key]: value }) as R;
},
});