Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NoPromises = errors.New("no promises specified")
NoPromises is used for Race where it is expected that promises will be set.
Functions ¶
func All ¶
All is used to return all results when all promises have resolved. If one promise rejects, the error will be returned.
Types ¶
type Promise ¶
type Promise[T any] struct { // contains filtered or unexported fields }
Promise is a promise that can be resolved or rejected. Note that manually creating this will result in blank values. You probably want to use .NewRejected, .NewResolved, or .NewFn instead.
func Catch ¶
Catch is used to add a error catching handler to the promise. In the event that the promise has already resolved, this will result in a new go-routine being spawned.
func NewRejected ¶
NewRejected is used to create a new rejected promise.
func NewResolved ¶
NewResolved is used to create a new resolved promise.
func Then ¶
Then is used to add a then handler to the promise. In the event that the promise has already resolved, this will result in a new go-routine being spawned.
func (*Promise[T]) Resolve ¶
func (p *Promise[T]) Resolve() *PromiseResolution[T]
Resolve is used to get the promise resolution. Returns a nil pointer if the promise is unresolved.
type PromiseResolution ¶
type PromiseResolution[T any] struct { // Result defines the result of the promise. Result T // Error defines if the promise rejected. Error error }
PromiseResolution is used to define the resolution of a promise.