Worker class

The Worker class represents a WebWorker. The events workercreated and workerdestroyed are emitted on the page object to signal the worker lifecycle.

page.onWorkerCreated
    .listen((worker) => print('Worker created: ${worker.url}'));
page.onWorkerDestroyed
    .listen((worker) => print('Worker destroyed: ${worker.url}'));
print('Current workers:');
for (var worker in page.workers) {
  print('  ${worker.url}');
}

Constructors

Worker(Client client, String? url, {required void onConsoleApiCalled(ConsoleAPICalledEventType, List<JsHandle>, StackTraceData?)?, required void onExceptionThrown(ExceptionThrownEvent)?})

Properties

client → Client
final
executionContext Future<ExecutionContext>
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String?
final

Methods

evaluate<T>(String pageFunction, {List? args}) Future<T?>
If the function passed to the Frame.evaluate returns a Promise, then Frame.evaluate would wait for the promise to resolve and return its value.
evaluateHandle<T extends JsHandle>(String pageFunction, {List? args}) Future<T>
The only difference between Worker.evaluate and Worker.evaluateHandle is that Worker.evaluateHandle returns in-page object (JSHandle).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited