some fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Ref, ref, watch } from 'vue';
|
||||
import { onUnmounted, Ref, ref, watch } from 'vue';
|
||||
import { $i } from './account';
|
||||
import { api } from './os';
|
||||
|
||||
@@ -104,8 +104,16 @@ export class Storage<T extends StateDef> {
|
||||
* 主にvue場で設定コントロールのmodelとして使う用
|
||||
*/
|
||||
public makeGetterSetter<K extends keyof T>(key: K, getter?: (v: T[K]) => unknown, setter?: (v: unknown) => T[K]) {
|
||||
// TODO: VueのcustomRef使うと良い感じになるかも
|
||||
const valueRef = ref(this.state[key]);
|
||||
|
||||
const stop = watch(this.reactiveState[key], val => {
|
||||
valueRef.value = val;
|
||||
});
|
||||
onUnmounted(() => {
|
||||
stop();
|
||||
});
|
||||
|
||||
// TODO: VueのcustomRef使うと良い感じになるかも
|
||||
return {
|
||||
get: () => {
|
||||
if (getter) {
|
||||
|
Reference in New Issue
Block a user