This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readonly, toRefs, type Ref } from "vue" | |
/** | |
* reactiveオブジェクトのすべてのプロパティをreadonlyなrefに変換する | |
* @param reactiveObj reactiveオブジェクト | |
* @returns readonlyなrefのオブジェクト | |
*/ | |
export function toReadonlyRefs<T extends Record<string, any>>(reactiveObj: T) { | |
const refs = toRefs(reactiveObj) | |
const readonlyRefs = {} as { [K in keyof T]: Readonly<Ref<T[K]>> } |