Class

org.scalajs.dom

Worker

Related Doc: package dom

Permalink

class Worker extends EventTarget with AbstractWorker

The Worker interface represents a background task that can be easily created and can send messages back to their creators. Creating a worker is as simple as calling the Worker() constructor, specifying a script to be run in the worker thread.

Of note is the fact that workers may in turn spawn new workers as long as those workers are hosted within the same origin as the parent page. In addition, workers may use XMLHttpRequest for network I/O, with the exception that the responseXML and channel attributes on XMLHttpRequest always return null.

Annotations
@JSType() @native() @JSGlobal()
Linear Supertypes
AbstractWorker, EventTarget, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Worker
  2. AbstractWorker
  3. EventTarget
  4. Object
  5. Any
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Worker(scriptURL: String)

    Permalink
  2. new Worker(scriptURL: String, options: WorkerOptions)

    Permalink

    scriptURL

    A USVString representing the URL of the script the worker will execute. It must obey the same-origin policy.

    options

    An object containing option properties that can be set when creating the object instance.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addEventListener[T <: Event](type: String, listener: Function1[T, _], options: EventListenerOptions): Unit

    Permalink

    The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on.

    The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

    This implementation accepts a settings object of type EventListenerOptions.

    Definition Classes
    EventTarget
  5. def addEventListener[T <: Event](type: String, listener: Function1[T, _], useCapture: Boolean = js.native): Unit

    Permalink

    The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on.

    The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

    Definition Classes
    EventTarget
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def dispatchEvent(evt: Event): Boolean

    Permalink

    Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order.

    Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

    Definition Classes
    EventTarget
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. var onerror: Function1[ErrorEvent, _]

    Permalink

    The AbstractWorker.onerror property represents an EventHandler, that is a function to be called when the error event occurs and bubbles through the Worker.

    The AbstractWorker.onerror property represents an EventHandler, that is a function to be called when the error event occurs and bubbles through the Worker.

    Definition Classes
    AbstractWorker
  21. var onmessage: Function1[MessageEvent, _]

    Permalink

    The Worker.onmessage property represents an EventHandler, that is a function to be called when the message event occurs.

    The Worker.onmessage property represents an EventHandler, that is a function to be called when the message event occurs. These events are of type MessageEvent and will be called when the worker calls its own postMessage() method: it is the way that a Worker has to give back information to the thread that created it.

  22. def postMessage(message: Any, transfer: UndefOr[Array[Transferable]] = js.native): Unit

    Permalink

    The postMessage() method of the Worker interface sends a message to the worker's inner scope.

    The postMessage() method of the Worker interface sends a message to the worker's inner scope. This accepts a single parameter, which is the data to send to the worker. The data may be any value or JavaScript object handled by the structured clone algorithm, which includes cyclical references.

    The Worker can send back information to the thread that spawned it using the DedicatedWorkerGlobalScope.postMessage method.

    message

    The object to deliver to the worker; this will be in the data field in the event delivered to the DedicatedWorkerGlobalScope.onmessage handler. This may be any value or JavaScript object handled by the structured clone algorithm, which includes cyclical references.

    transfer

    An optional array of Transferable objects to transfer ownership of. If the ownership of an object is transferred, it becomes unusable in the context it was sent from and becomes available only to the worker it was sent to. Transferable objects are instances of classes like ArrayBuffer, MessagePort or ImageBitmap objects that can be transferred. null is not an acceptable value for transfer.

  23. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  24. def removeEventListener[T <: Event](type: String, listener: Function1[T, _], options: EventListenerOptions): Unit

    Permalink

    Removes the event listener previously registered with EventTarget.addEventListener.

    Removes the event listener previously registered with EventTarget.addEventListener.

    This implementation accepts a settings object of type EventListenerOptions.

    Definition Classes
    EventTarget
  25. def removeEventListener[T <: Event](type: String, listener: Function1[T, _], useCapture: Boolean = js.native): Unit

    Permalink

    Removes the event listener previously registered with EventTarget.addEventListener.

    Removes the event listener previously registered with EventTarget.addEventListener.

    Definition Classes
    EventTarget
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def terminate(): Unit

    Permalink

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

    The Worker.terminate() method immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is simply stopped at once.

  28. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  31. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AbstractWorker

Inherited from EventTarget

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped