📄 index.ts¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 2 |
| 📦 Imports | 6 |
| 🟢 Vue Composition API | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/core/useObjectUrl/index.ts
📦 Imports¶
| Name | Source |
|---|---|
MaybeRefOrGetter |
vue |
tryOnScopeDispose |
@vueuse/shared |
readonly |
vue |
shallowRef |
vue |
toValue |
vue |
watch |
vue |
Vue Composition API¶
| Name | Type | Reactive Variables | Composables |
|---|---|---|---|
watch |
watch | none | none |
Functions¶
useObjectUrl(object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>): any¶
Code
export function useObjectUrl(object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>) {
const url = shallowRef<string | undefined>()
const release = () => {
if (url.value)
URL.revokeObjectURL(url.value)
url.value = undefined
}
watch(
() => toValue(object),
(newObject) => {
release()
if (newObject)
url.value = URL.createObjectURL(newObject)
},
{ immediate: true },
)
tryOnScopeDispose(release)
return readonly(url)
}
-
JSDoc:
-
Parameters:
object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>- Return Type:
any - Calls:
shallowRef (from vue)URL.revokeObjectURLwatch (from vue)toValue (from vue)releaseURL.createObjectURLtryOnScopeDispose (from @vueuse/shared)readonly (from vue)
release(): void¶
- Return Type:
void - Calls:
URL.revokeObjectURL