Documentation
¶
Overview ¶
Package promise provides a Go way to represent the concept of a Promise.
In JavaScript, a promise represents an operation that will fulfill with a value in the future, or produce an error. The outcome of the operation is represented by generic type Result, containing either an error or a fulfilled value. The generic Promise type is just a channel where the value will be received.
This package is not intended to provide be a full implementation of JavaScript promises. The intention is to simplify implementation of web APIs that returns promises, e.g. the fetch API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrAny ¶
type ErrAny struct{ Reason any }
ErrAny wraps any value as a valid go [error] value. While errors originating from Go code will always be instances of error, in JavaScript, any value can be an error.
When an error is generated in JavaScript code, and not representable directly as an error in Go, ErrAny will represent the value.
TODO: This isn't specific to promises, but there's not really another package that's a good fit ATM, and I don't want to create a new package just to have this type. Consider moving in the future