koel/resources/assets/js/composables/useModal.ts
2024-10-14 00:37:01 +07:00

11 lines
327 B
TypeScript

import { requireInjection } from '@/utils'
import { ModalContextKey } from '@/symbols'
import type { Ref } from 'vue'
export const useModal = () => {
const [modalContext] = requireInjection<[Ref<Record<string, any>>]>(ModalContextKey)
return {
getFromContext: <T> (key: string) => modalContext.value[key] as T,
}
}