feat: add caching for backend objects
This commit is contained in:
10
app/composables/useOfflineStatus.ts
Normal file
10
app/composables/useOfflineStatus.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
const _isOnline = ref(typeof navigator !== 'undefined' ? navigator.onLine : true)
|
||||
|
||||
if (import.meta.client) {
|
||||
window.addEventListener('online', () => { _isOnline.value = true })
|
||||
window.addEventListener('offline', () => { _isOnline.value = false })
|
||||
}
|
||||
|
||||
export function useOfflineStatus() {
|
||||
return { isOnline: readonly(_isOnline) }
|
||||
}
|
||||
Reference in New Issue
Block a user