worker

package
v0.0.0-...-786626a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseHandler

type ResponseHandler func(content *js.Object)

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker is a wrapper around a webworker.

This is run from the page to manage a webworker being run in the background.

func NewForCode

func NewForCode(jsCode string) *Worker

NewForCode creates a new webworker that runs the given JS code.

WARNING: This is not safe to do normally since it is an injection sink. Here it is fine because we're running on a secure host, gopherjs.github.io. Just promise not to do this in any other location without first understanding the security concerns.

func NewForUrl

func NewForUrl(url string) *Worker

NewForUrl creates a new webworker for the given url.

func (*Worker) SendMessage

func (w *Worker) SendMessage(msgType string, content any) bool

func (*Worker) SetResponseHandler

func (w *Worker) SetResponseHandler(msgType string, handler ResponseHandler)

func (*Worker) Terminate

func (w *Worker) Terminate()

Terminate will immediately kill the webwoker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL