Module

Web.Worker.Worker

Package
purescript-web-workers
Repository
purescript-web/purescript-web-workers

This module contains function to create and control workers from the parent's worker

#Worker Source

data Worker

#new Source

new :: String -> WorkerOptions -> Effect Worker

creates a worker object that executes the script at the specified URL.

#onMessage Source

onMessage :: (MessageEvent -> Effect Unit) -> Worker -> Effect Unit

fired when the worker's parent receives a message from its worker

#onMessageError Source

onMessageError :: (MessageEvent -> Effect Unit) -> Worker -> Effect Unit

fired when the worker's parent receives a message that can't be deserialized.

#onError Source

onError :: (Event -> Effect Unit) -> Worker -> Effect Unit

fired when an error occurs in the worker.

#postMessage Source

postMessage :: forall msg. IsSendable msg => msg -> Worker -> Effect Unit

sends a message to the worker's inner scope.

#postMessage' Source

postMessage' :: forall msg. IsSendable msg => msg -> Array Transferable -> Worker -> Effect Unit

#terminate Source

terminate :: Worker -> Effect Unit

immediately terminates the worker. This does not offer the worker an opportunity to finish its operations; it is stopped at once.

Re-exports from Web.Worker.Options

#WorkerType Source

#WorkerOptions Source

type WorkerOptions = { name :: String, type :: WorkerType }

#Credentials Source