execution library
Flutter-free execution registry shared by the page, the compiled Web Worker bundle and (via that bundle) the Service Worker.
The callback dispatcher compiled into the worker bundle cannot import
Flutter packages, so the small execution contract used by a dispatcher
lives in this library instead of in package:workmanager_web/workmanager_web.dart.
A dispatcher written for the web registers its handler with WorkmanagerExecution.executeTask:
void callbackDispatcher() {
WorkmanagerExecution.instance.executeTask((taskName, inputData) async {
// Flutter-free background work only.
return true;
});
}
Classes
- WorkmanagerExecution
- Shared registry that holds the currently registered background task handler.
Typedefs
-
BackgroundTaskHandler
= Future<
bool> Function(String taskName, Map<String, dynamic> ? inputData) - Signature of the handler invoked when a background task runs.
- PageMessageSender = void Function(Object? payload)
- Signature used by dispatcher code to push a free-form message back to the page while a task or message handler is running.
- WorkerMessageHandler = void Function(Object? payload)
-
Signature of the handler invoked when the page sends a free-form message
to the background worker (see
WorkmanagerWeb.sendMessageToWorker).