@rtorcato/browser-common / backgroundtasks
backgroundtasks
Functions
isBackgroundSyncAvailable()
isBackgroundSyncAvailable():
boolean
Defined in: backgroundtasks/index.ts:26
Checks if Background Tasks (Background Sync or Background Fetch) are available in the current environment.
Returns
boolean
Example
import { isBackgroundSyncAvailable } from '@rtorcato/browser-common/backgroundtasks'
if (isBackgroundSyncAvailable()) registerSync()
isBackgroundFetchAvailable()
isBackgroundFetchAvailable():
boolean
Defined in: backgroundtasks/index.ts:38
Checks if the Background Fetch API is available in the current environment.
Returns
boolean
Example
import { isBackgroundFetchAvailable } from '@rtorcato/browser-common/backgroundtasks'
if (isBackgroundFetchAvailable()) queueDownload()
registerBackgroundSync()
registerBackgroundSync(
tag):Promise<void>
Defined in: backgroundtasks/index.ts:52
Registers a background sync task (if supported).
Parameters
tag
string
The sync event tag name.
Returns
Promise<void>
A promise that resolves when registered, or undefined if not supported.
Example
import { registerBackgroundSync } from '@rtorcato/browser-common/backgroundtasks'
await registerBackgroundSync('sync-outbox')
registerBackgroundFetch()
registerBackgroundFetch(
tag,urls,options?):Promise<any>
Defined in: backgroundtasks/index.ts:71
Registers a background fetch task (if supported).
Parameters
tag
string
The fetch event tag name.
urls
string[]
The URLs to fetch.
options?
BackgroundFetchOptions
Optional BackgroundFetchOptions.
Returns
Promise<any>
A promise that resolves to the BackgroundFetchRegistration, or undefined if not supported.
Example
import { registerBackgroundFetch } from '@rtorcato/browser-common/backgroundtasks'
await registerBackgroundFetch('media', ['/video.mp4'], { title: 'Video' })