jspromise

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package jspromise provides a simple JavaScript Promise implementation for Go WebAssembly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(promises []js.Value) ([]js.Value, error)

All waits for all promises to resolve and returns their values.

func Await

func Await(promise js.Value) (js.Value, error)

Await waits for a Promise to settle and returns its value or error.

func Catch

func Catch(promise js.Value, onRejected func(error)) js.Value

Catch attaches a callback to a promise for when it rejects.

func New

func New() (js.Value, func(interface{}), func(interface{}))

New creates a new JavaScript Promise and returns the promise along with resolve and reject callbacks. The returned callbacks can be called from Go to resolve or reject the promise.

func Race

func Race(promises []js.Value) (js.Value, error)

Race returns the result of the first promise to settle.

func Reject

func Reject(reason interface{}) js.Value

Reject creates a Promise that is rejected with the given reason.

func Resolve

func Resolve(value interface{}) js.Value

Resolve creates a Promise that is resolved with the given value.

func Then

func Then(promise js.Value, onFulfilled func(js.Value)) js.Value

Then attaches a callback to a promise for when it resolves.

Types

type Promise

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

Promise represents a JavaScript Promise

Jump to

Keyboard shortcuts

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