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>)

Clones message and transmits it to worker's global environment. transfer can be passed as a list of objects that are to be transferred rather than cloned.

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

Aborts worker's associated global environment.

Link copied to clipboard