diff options
Diffstat (limited to 'src/client/pizzax.ts')
| -rw-r--r-- | src/client/pizzax.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/pizzax.ts b/src/client/pizzax.ts index 02a1bf8bdc..127f543003 100644 --- a/src/client/pizzax.ts +++ b/src/client/pizzax.ts @@ -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) { |