Merge upstream changes #5

Merged
yume merged 26 commits from develop into master 2024-11-08 23:26:56 -06:00
Showing only changes of commit f1eb17f66c - Show all commits

View file

@ -241,9 +241,13 @@ export class Storage<T extends StateDef> {
* getter/setterを作ります * getter/setterを作ります
* vue上で設定コントロールのmodelとして使う用 * vue上で設定コントロールのmodelとして使う用
*/ */
public makeGetterSetter<K extends keyof T>(key: K, getter?: (v: T[K]) => unknown, setter?: (v: unknown) => T[K]): { public makeGetterSetter<K extends keyof T, R = T[K]['default']>(
get: () => T[K]['default']; key: K,
set: (value: T[K]['default']) => void; getter?: (v: T[K]['default']) => R,
setter?: (v: R) => T[K]['default'],
): {
get: () => R;
set: (value: R) => void;
} { } {
const valueRef = ref(this.state[key]); const valueRef = ref(this.state[key]);
@ -265,7 +269,7 @@ export class Storage<T extends StateDef> {
return valueRef.value; return valueRef.value;
} }
}, },
set: (value: unknown) => { set: (value) => {
const val = setter ? setter(value) : value; const val = setter ? setter(value) : value;
this.set(key, val); this.set(key, val);
valueRef.value = val; valueRef.value = val;