Worker

open class Worker(scriptURL: String, options: WorkerOptions = definedExternally) : EventTarget, AbstractWorker, MessageEventTarget(source)

The Worker interface of the Web Workers API represents a background task that can be created via script, which can send messages back to its creator.

MDN Reference

Constructors

Link copied to clipboard
constructor(scriptURL: URL, options: WorkerOptions = definedExternally)
constructor(scriptURL: String, options: WorkerOptions = definedExternally)

Functions

Link copied to clipboard
Link copied to clipboard
fun postMessage(message: JsAny?, transfer: ReadonlyArray<Transferable>)

The postMessage() method of the Worker interface sends a message to the worker.

fun postMessage(message: JsAny?, options: StructuredSerializeOptions = definedExternally)
Link copied to clipboard
fun terminate()

The terminate() method of the Worker interface immediately terminates the Worker.

Link copied to clipboard