jsext

package module
v2.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: GPL-2.0 Imports: 1 Imported by: 1

README

JSExt!

Golang Wasm extension for easy JS interop.

A simple library for more easily interacting with Javascript like you are used to.

Binary sizes

When compiling with the regular go compiler, the binary sizes can get pretty big. We do implement a page loader, but this may not be your way to go. This is why we recomment starting out with TinyGO, as the binary sizes are much smaller, but even that could get pretty large without any optimizations. If you do suffer binary size issues, you can try to use the -ldflags="-s -w" flag when compiling with the regular go compiler. When compiling with TinyGO, you can try to use the -no-debug flag, which will remove debug information from the binary. There are also some great optimization tools for WebAssembly, such as WasmOpt, which can be used to optimize the binary size, or speed. You can find more information about wasm-opt here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Promise

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

func NewPromise

func NewPromise(f func() (any, error)) Promise

Create a new Promise.

func NewPromiseResolve

func NewPromiseResolve(value any) Promise

Create a new Promise that resolves to the given value.

func (Promise) Catch

func (w Promise) Catch(f func(error)) Promise

Catch an error from the Promise.

func (Promise) MarshalJS added in v2.7.6

func (w Promise) MarshalJS() js.Value

Returns the js.Value of the Promise.

func (Promise) Then

func (w Promise) Then(f func(Value)) Promise

Then a function on the Promise.

func (Promise) Value

func (w Promise) Value() Value

Returns the jsext.Value of the Promise.

Jump to

Keyboard shortcuts

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