Worker class

The interface of the Web Workers API represents a background task that can be created via script, which can send messages back to its creator. Creating a worker is done by calling the Worker("path/to/worker/script") constructor. Workers may themselves spawn new workers, as long as those workers are hosted at the same origin as the parent page. (Note: nested workers are not yet implemented in WebKit). Not all interfaces and functions are available to scripts inside a . Workers may use XMLHttpRequest for network communication, but its responseXML and channel attributes are always null. (fetch is also available, with no such restrictions.)

EventTarget

Worker

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Worker(String scriptURL, [WorkerOptions? options])
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
onerror EventHandlerNonNull<Event>?

Available on AbstractWorker, provided by the PropsAbstractWorker extension

getter/setter pair
onmessage EventHandlerNonNull<Event>?

Available on Worker, provided by the PropsWorker extension

getter/setter pair
onmessageerror EventHandlerNonNull<Event>?

Available on Worker, provided by the PropsWorker extension

getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addEventListener(String type, EventListener? callback, [dynamic options]) → void

Available on EventTarget, provided by the PropsEventTarget extension

dispatchEvent(Event event) bool

Available on EventTarget, provided by the PropsEventTarget extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postMessage(dynamic message, Iterable transfer) → void

Available on Worker, provided by the PropsWorker extension

removeEventListener(String type, EventListener? callback, [dynamic options]) → void

Available on EventTarget, provided by the PropsEventTarget extension

terminate() → void

Available on Worker, provided by the PropsWorker extension

toString() String
A string representation of this object.
inherited

Operators

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