Class: Worker

ol.ext. Worker

Worker helper to create a worker from code


new Worker(mainFn, options)

Parameters:
Name Type Description
mainFn function

main worker function

options object
Properties
Name Type Argument Description
onMessage function <optional>

a callback function to get worker result

Methods


onMessage(fn)

Set onMessage callback

Parameters:
Name Type Description
fn function

a callback function to get worker result


postMessage(message [, restart])

Post a new message to the worker

Parameters:
Name Type Argument Default Description
message object
restart boolean <optional>
false

stop the worker and restart a new one


start()

Terminate current worker and start a new one


terminate()

Terminate a worker